Forum Moderators: phranque
RewriteRule ^/([^/]+)/?$ /?p=$1 [L]
This row gives the result "//about/" and when I try to delete the slash after ^ I get 500 Internal Error
Here is the full code of .htaccess
----
# Enable mod_rewrite, start rewrite engine
Options +FollowSymLinks
RewriteEngine on
#
# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteRule ^/([^/]+)/?$ /?p=$1 [L]
#
# Externally redirect client requests for old dynamic URLs to equivalent new static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?p=([^\ ]+)\ HTTP/
RewriteRule ^$ [mysite.com...] [R=301,L]
----
Please help.
In this case, you should rewrite to a fully-defined URL-path, not to "/" followed by "?p=$1"
And if the script path matches the rule pattern, then you'll need to exclude the script path from the rewrite to prevent the loop.
In other words:
RewriteCond %{REQUEST_URI} !^/my-script\.php$
RewriteRule ^/([^/]+)/?$ /my-script.php?p=$1 [L]
Otherwise, DirectoryIndex will get involved in translating "/" to a filepath, and will complicate matters.
Jim