Help with mod-rewrite

by 7 replies
8
This is a simple rule but its giving me some trouble.

Im trying to redirect a URL like this

sitename.com/events/312.html

to this

sitename.com/showpage.php?p=312

Im using:

RewriteRule ^/events/([^/]*)\.html$ /showpage.php?p=$1 [L]

However it is not working. Any assistance would be greatly appreciated.
#programming #modrewrite
  • This is a Rule without Condition... you need a Redirect, AFAIK

    RewriteRule ^/events/(.*)\.html$ /showpage.php?p=$1 [L,R=301]

    This might work, I am not really a regex freak (hate it)...

    However, I would check your error logs as well
  • Didnt make a difference Thanks for responding though.
  • This works fine for me:

    RewriteEngine On
    RewriteRule ^events/(.*)\.html$ showpage.php?p=$1 [L]
    • [1] reply
    • Yea its really strange, Im sure both my original and this new one should have worked, but neither do. This is on a GoDaddy server, so IDK its all screwy, might be GoDaddy.
  • Ended up using:

    ^events/([^/]*)\.html$ /showpage.php?p=$1 [L]
  • Funny how different servers have different requirements, isn't it? I've never memorized all the inconsistencies, sometimes it just takes fiddling.

    Thank God for Python, right? :p
    • [1] reply

Next Topics on Trending Feed