: Is it possible to mod_rewrite BASED on the existence of a file/directory and uniqueID? My site currently forces all non-www. pages to use www. Ultimately, I am able to handle all unique subdomains
My site currently forces all non-www. pages to use
Ultimately, I am able to handle all unique subdomains and parse correctly but I am trying to achieve the following (ideally with mod_rewrite):
When a consumer visits example.com/john4, the server processes that request as: example.com?Agent=john4
Our requirements are:
The URL should continue to show example.com/john4 even though it was redirected to example.com/index.php?Agent=john4 If a file (of any extension OR a directory) exists with the name, the entire process stops an it tries to pull that file instead:
For example: example.com/file would pull up (www.example.com/file.php if file.php existed on the server. example.com/pages would go to example.com/pages/index.php if the pages directory exists).
More posts by @Hamaas447
2 Comments
Sorted by latest first Latest Oldest Best
If you turn on MultiViews, you can do this, as it will search for request-uri.* first before running the RewriteRule.
Options +MultiViews
RewriteEngine On
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?Agent= [L]
Try this (untested)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?Agent= [L]
</IfModule>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.