How to keep original URL in addressbar after RewriteRule
10,753
Have it this way:
Options +FollowSymLinks
RewriteEngine on
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
RewriteCond %{THE_REQUEST} /index\.html [NC]
RewriteRule ^index\.html$ /? [R=301,L,NC]
RewriteRule ^listen/$ /console/ [NC,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [L,QSA]
Test it after clearing your browser cache.
Author by
extra stereo
Updated on June 04, 2022Comments
-
extra stereo almost 2 years
This is my .htaccess file.
Options +FollowSymLinks <IfModule mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </IfModule> RewriteEngine on RewriteRule ^index.html /? [R=301,L] RewriteRule ^listen/$ /console [R=301,L] # 301 Redirect all requests that don't contain a dot or trailing slash to # include a trailing slash RewriteCond %{REQUEST_URI} !/$ RewriteCond %{REQUEST_URI} !\. RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L] # Rewrites urls in the form of /parent/child/ # but only rewrites if the requested URL is not a file or directory RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php?page=$1 [QSA]
The rewrite rule
RewriteRule ^listen/$ /console [R=301,L]
Redirects the url
www.mydomain.co.uk/listen
towww.mydomain.co.uk/console
This redirect works fine, but I want the visable url in the address bar to read...
www.mydomain.co.uk/listen
Any help greatly appreciated. Thanks