: Simple RewriteRule I'm trying to write a RewriteRule to make a simple url. I want users to be able to type enter www.example.com/somepage and have it take them to www.example.com/abc/somepage.php
I'm trying to write a RewriteRule to make a simple url. I want users to be able to type enter
example.com/somepage
and have it take them to
example.com/abc/somepage.php
How can this be done in .htaccess?
I've tried these to no avail:
RewriteRule ^somepage$ abc/somepage.php [L]
RewriteRule ^/somepage$ /abc/somepage.php [L]
Your help is much appreciated.
More posts by @Murray432
1 Comments
Sorted by latest first Latest Oldest Best
Assuming this is in the .htaccess in your document root, then you are almost there. You just seem to be missing the / (slash - directory separator) from the front of your destination URL (in the first example).
RewriteEngine On
RewriteRule ^somepage$ /abc/somepage.php [R=301,L]
The slash (or whatever is the base URL) is automatically removed from the request URI when pattern matching, which is why it is not present in the pattern (^somepage$).
This will perform an external redirect (R=301) - so the destination URL will show in the browser. Remove the R flag to perform an internal rewrite (URL won't change).
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.