Forum Moderators: phranque

Message Too Old, No Replies

new server, mod_rewrite not working

Installed a new server, enabled mod_rewrite but its not working.

         

mikeseo

7:38 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



I installed a new redhat server and am trying to get mod_rewrite working.

Both these lines are uncommended in httpd.conf
LoadModule rewrite_module
AddModule mod_rewrite.c

I have also done
<Directory />
Options All
AllowOverride All
</Directory>

.htaccess file looks like
ErrorDocument 404 [domain.com...]

but when I type in www.domain.com/sdfgkjdf.html it receives a 404 error and is not redirected.

info.php shows mod_rewrite enabled.

Any ideas would be appreciated, thanks.

wfernley

7:44 pm on Apr 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On one of my new servers I had the same problem.

I did a cheap fix and just changed the ErrorDocument in the httpd.conf file. Can you do that, or did you want to run it in the .htaccess file?

Wes

mikeseo

7:47 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



I want to run a bunch more stuff in .htaccess , I'm just using ErrorDocument for a test to get it working. The other stuff isn't working either.

wfernley

7:50 pm on Apr 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well I found one of my sites wouldn't run ErrorDocument but the rest of the mod_rewrite rules worked fine.

Maybe there is something extra that is missing for the ErrorDocument. I wouldnt be able to help you with that sorry :(.

What else are you trying to run though?

Wes

mikeseo

8:01 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



ErrorDocument 404 [site.com...]
AddHandler server-parsed .html
RewriteEngine On
RewriteRule ^([^-]+)-([^-]+)\.html$ /index.php/?terms=$1\%20$2 [NE,L]
RewriteRule ^(.+)\.html$ /index.php/?terms=$1 [L]

Got a simple mod_rewrite I could use to test?

mikeseo

9:18 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



.htaccess contains:
RewriteEngine on
RewriteRule google.html [google.com...]

And www.site.com/google.html is not redirecting to www.google.com

Do I have to specify a directory in <Directory />?

mikeseo

10:21 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



hmm I changed AllOverride None to All in a second place and it works. Is it correct though?

# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride All

jdMorgan

4:40 am on Apr 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The syntax of the following line is incorrect:

ErrorDocument 404 Http://www.example.com

The result of this will be a 302-Found (Moved Temporarily) response, rather than a 404-Not Found. Also, "Http" should not be capitalized.

The correct syntax is:


ErrorDocument 404 /

Normally, you'd put a local URL-path where "/" is shown. However, your intent is apparently to forward all missing pages to your home page. So, the syntax shown is correct to do so; ErrorDocument requires a local URL-path, not a canonical URL if a 404 response is desired. See the ErrorDocument documentation [httpd.apache.org] for details.

However, I strongly suggest you do not use your home page as an error document if you care about search engine ranking. Doing so runs the risk of your home page URL disappearing, to be replaced in search results by one of the missing page URLs. Do a search for 'duplicate content penalty' -- an unfortunate misnomer -- for descriptions of how a search engine may list 'the wrong' page if you confuse it.

Jim