I'm trying to rewrite a url that looks like http://example.com/View/(random_text) to take the user to http://example.com/View/site.php?site=(random_text)
This is what I am ussing so far:
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^View/(.+)$ View/site.php?site=$1 [NC]
Any help is appreciated, thanks.
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/View/(.+)$ /View/site.php?site=$2 [L,R=301]
If the "View" directory is in your webserver's root directory, then add just the single forward slash as above. Else add the path to the view directory like below:
RewriteRule ^(.*)/View/(.+)$ /path_to_view_directory/View/site.php?site=$2 [L,R=301]