Forum Moderators: phranque
i m using the following rule and i m sure it can be much better, i ve very lil experience with rewriting. so help.
i want my index.php file to open when typed www.domain.com/some-directory/
but i ve defined some rule to rewrite any page like this some-directory/some-page.php to this some-directory/services.php?name=(some-page)
RewriteRule some-directory/(.*)$ /services.php?name=$1
problem is above defined rule takes every request to the services.php page, i ve tried the following rule too
RewriteRule some-directory/[^(index)](.*)$ /services.php?name=$1
but i ve not been able exclude the index.php from being processed. can someone plz tell how to group the text correctly and exclude it.
thanks
Welcome to WebmasterWorld!
Just add a Rewrite Condition ahead of the rule to exclude /some-directory/index.php from being rewritten:
RewriteCond %{REQUEST_URI} !^/some-directory/index\.php$
RewriteRule ^some-directory/(.*)$ /services.php?name=$1 [L]
Jim
there was a lil problem though, code worked fine for index.php at the end of path but it did not work when there was only domain/some-dir/
i had to add some to check the '/', modified code was
RewriteCond %{REQUEST_URI}!^/some-dir/index\.php$
RewriteRule ^some-dir/[^/](.*)$ /services.php?name=$1 [L]
even though its working fien now but is there a better way to do it?
btw, thanks for welcoming. :)
-Ali