Reputation:
I have a url like this.
/domains/details.php
(NOTE: domains
is dynamic and can be anything)
How do I remove the domains
part from the URL using .htaccess so the actual lookup is:
/details.php
OR it'll be cool if I can get domains
into the URL.
/details.php?page=domains
Thanks! Scott
Upvotes: 2
Views: 12496
Reputation: 1004
Please try to use the following rules to deal with your last request:
RewriteRule ^(?!domains/.*)([^/]+)/details.php$ domains/details.php?page=$1 [R=301,QSA]
RewriteRule ^domains/details.php$ details.php [NC,L]
Upvotes: 1
Reputation: 143314
RewriteEngine on
RewriteBase /
RewriteRule ^([^/]+)/details.php$ /details.php?page=$1 [R=301]
Leave off the [R=301]
if you want an internal redirect rather than an actual HTTP redirect.
To preserve existing query parameters you can change the rule to this:
RewriteRule ^([^/]+)/details.php(.*)$ /details.php?page=$1&%{QUERY_STRING} [R=301]
Upvotes: 5