I’m successfully using mod_rewrite to grab the url and pass it as a parameter but only when the url has a prefix of at least one character.
The .htaccess file is in the directory www.site.com/content
For example, the following Rewrite succeeds: (site.com/content/-seo-friendly-url)
RewriteEngine on
RewriteRule ^content-(.*)$ ./get_content.php?url=$1
but this example does not work: (site.com/content/seo-friendly-url)
RewriteEngine on
RewriteRule ^(.*)$ ./get_content.php?url=$1
I get a 500 Internal Server Error
and this gets a 404 Not Found
RewriteRule ^([a-zA-Z0-9-])$ ./get_content.php?url=$1
and this passes ‘get_content’ as the ($1) parameter to get_content.php with no error
RewriteRule ^(.*)$ get_content.php?url=$1
The goal is to pass the url to get_content.php without a prefix.
For example,
www.site.com/content/seo-friendly-url
should be rewritten to
www.site.com/content/get_content.php?url=seo-friendly-url
2
Answers
try this. I haven’t tested this code, but I’m pretty sure it may help you
RewriteEngine On
RewriteRule ^content/get_content.php?url=seo-friendly-url$ /content/seo-friendly-url [L]
If this didn’t work i recommend to use this site. It helped me with a lot of rewrite’s
Click this link!
Try this rule,