Hi, I have been trying to write a set of htaccess rules that will do the following:
With the url: mydomain.com/blog/something
If a file called blog.php exists in
the web directory(the directory with index.php in) then redirect to
blog.php?url=somethingIf blog.php does not exist, redirect to index.php?url=blog/something
EDIT: mydomain.com/blog/something is an example, it could be any url string and the htaccess should search the web directory for a file corresponding to the first part of the url string, which in this case is "blog"
In both cases I can then use $_GET['url'] to get parameters from the url to intiate whatever actions in my php script.
I currently have:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/(.*)$ $1.php?url=$2 [L]
RewriteRule ^(.*)$ index.php?url=$1 [L]
</IfModule>
But unfortunately this is not working, I'm not sure why, I'm proficient enough with php but my htaccess skills are pretty limited. I don't know if the [L] option is the one I should be using or if I should be using more options. Currently whatever the url string is, $_GET['url'] returns "index.php".
If any more information is required just ask.
I hope someone can help Regards Luke