Forum Moderators: phranque

Message Too Old, No Replies

.htaccess rewrite help

         

KevinC

3:29 am on Apr 12, 2006 (gmt 0)

10+ Year Member



I'm just curious if there is anything that jumps out in this script that would cause this not to work?

RewriteEngine on
Options +FollowSymlinks
RewriteBase /

# pages
RewriteRule ^([a-z0-9-]+)\.shtml$ /index.php?title=$1

# protect htaccess file
RewriteRule ^.htaccess*$ - [F]

Thank a lot!

jdMorgan

1:36 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Cause it not to work?

No, but the literal period in the ".htaccess" pattern should be escaped, and removing the start anchor would allow it to protect .htaccess files in subdirectories as well as the directory where the code is located. The "*" at the end appears to be spurious.


# protect htaccess file
RewriteRule \.htaccess$ - [F]

I also suggest that you always use the [L] flag, unless you have a specific requirement no to.

# pages
RewriteRule ^([a-z0-9-]+)\.shtml$ /index.php?title=$1 [L]

Do you have a specific problem with this code?

Jim

KevinC

5:24 pm on Apr 12, 2006 (gmt 0)

10+ Year Member



Hey Jim thanks for the reply,

Basically the rewrite is not working, but i just found out my host is running zeus and not apache - could that be causing the problem?

jdMorgan

1:04 am on Apr 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, that's a totally-different server! :(

Jim