I am trying to adjust my htacess file to skip the rewrite rule if the file or directory exists, but when the file exists, it changes the URL to something different. I don't know why this is happening. Here is my htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^project/([^/\.]+)/?$ index.php?view=project&project=$1 [L]
RewriteRule ^for/content/ag index.php?view=opening§ion=ag [L]
RewriteRule ^for/content/bus index.php?view=opening§ion=bus [L]
RewriteRule ^for/content/fcs index.php?view=opening§ion=fcs [L]
RewriteRule ^for/content/market index.php?view=opening§ion=market [L]
RewriteRule ^for/content/trade index.php?view=opening§ion=trade [L]
RewriteRule ^for/content/teched index.php?view=opening§ion=teched [L]
RewriteRule ^for/content/([^/\.]+)/?$ index.php?view=content_area§ion=$1 [L]
The directory /project/nti exists, with an index.php file. When the address mywebsite.com/folder/project/nti is entered, it changes to mywebsite.com/folder/project/nti/?view=project&project=nti. I am applying this on a test server where the sample site is in a subfolder, but when implemented, it will be in the root web server folder.
Thanks for any help!
Remove extra [OR]
and have your code like this:
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^project/([^/.]+)/?$ index.php?view=project&project=$1 [L,NC,QSA]