954,242 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

mod-rewrite on godaddy server

I am on a godaddy server now and trying this mod-rewrite stuff and it is still not working.
I have been searching google now for hours looking for the answer and cannot find it.

Here is my entire .htaccess file:
#Rewrite Rules
Options -MultiViews
Options +FollowSymLinks +Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)(/?)$ index.php?p=$1 [L]

#RewriteEngine On
#RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME}.php -f
#RewriteRule ^(.+)$ /$1.php [L,QSA]
#RewriteRule ^c/([^/.]+)/?$ index.php?p=$1 [L]


The stuff thats commented out is what I tried the first time, then I tried many many other ways to try and get this to work with no luck.
Thanks,
Brian

bjeffries
Junior Poster
143 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Anyone have any insight on this?

... the weird thing is I got an email saying someone replied to this and I dont see anything.

bjeffries
Junior Poster
143 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

What do you mean with "is not working"?
Your rule
RewriteCond %{REQUEST_FILENAME}.php -f requests that for a request like /abc
the file named /abc.php
exists. Is that what you want?
Your last rule will never catch anything in its second pair of brackets. In RewriteRule ^(.*)(/?)$ index.php?p=$1 [L]

the first bracket pair catches all content.

smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

My goal is to get a domain like this domain.com/training or domain.com/contact instead of domain.com/index.php?p=training.

I have checked numerous sites even a thread on here doing the same exact thing using the same exact example, and i believe he was also using a godaddy server. I used his same code and got nothing, eventually just confused myself because I have used so many different snippets from all over.

bjeffries
Junior Poster
143 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Anyone have any insight on this?

... the weird thing is I got an email saying someone replied to this and I dont see anything.


This happened because a spammer replied to your thread, but then a moderator deleted their post.

Try the .htaccess file:

RewriteEngine On
RewriteRule		^([a-z0-9]+).html$		index.php?p=$1	[L]


Then, blah.html will redirect to index.php?p=blah

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 

I have your code in there right now and its still not working. I almost positive that is something I have tried before also.

You can check it out at http://kbrlifestyles.com and just click on a link to see what I am talking about.

bjeffries
Junior Poster
143 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

The code is working. Try http://kbrlifestyles.com/bootcamp.html
Now you will have to modify it to suit your needs. Start with

RewriteRule	^([a-z0-9]+)(.htm(l)?)?$	index.php?p=$1	[L]
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

ok I see, so I actually need to change the link from "index.php?p=contact" to just "/contact"

This would not happen automatically?

bjeffries
Junior Poster
143 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

There is nothing in the IT world which happens automatically.
To make the /contact link work, you'll first have to install the modification from my previous post.

smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

Yeah, well it works. thats all that matters to me.

Thanks a bunch!!

bjeffries
Junior Poster
143 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Please mark this thread as solved.

smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: