Home Debugging SEO friendly URLs with mod rewrite
Reply: 0

Debugging SEO friendly URLs with mod rewrite

user1407 Published in May 22, 2018, 9:37 pm

I feel like I have a good handle on mod rewrite, but I cannot seem to get this one to work.

My setup: if a page actually exists (i.e. contact.php), then load the "real" page. Otherwise, assume that the url is a blog entry with a SEO friendly url, and feed that url to my index page as a querystring.

Example: http://www.example.org/my_latest_post should be rewritten to http://www.example.org/index.php?blogurl=my_latest_post

If I take the "ugly" url and paste it into the browser, the page loads fine. But if I run the SEO friendly url, I get the dreaded 404.

My htaccess file is actually quite light right now. Some caching stuff, piping XML to PHP (for a dynamic RSS feed), a custom 404 document.

Here is the relevant mod_rewite stuff:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(([A-Za-z0-9]+[-]+[A-Za-z0-9]+)+[/])$  index.php?blogurl=$1    [NC,L]

To my understanding, I'm saying that if the filename is part of an actual file or directory, then let it stand. My other pages all work normally, so this seems to work.

Then, everything else should be assumed to be part of an SEO url, and passed to index.php?blogurl=[the url].

But that's not working.

What stupidly obvious thing am I overlooking

Thanks for your help!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.561895 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO