I have some difficulties with the mod_rewrite rules. I want to rewrite any request on
www.example.com/dev/*
to
www.example.com/*
For example when the request url is www.example.com/dev/index.php
, the response should be www.example.com/dev/index.php
, and not just that the url looks like it's from the root directory, but it is actually using the index.php
from root directory.
I have tried the mod_alias which works
RedirectMatch (^/dev/)(.*) http://www.example.com/$2
But it is not possible to apply ip address conditions with mod_alias, so I still need a solution with mod_rewrite.
Would anyone share some knowledge please? Thanks.
htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.
How about something like this?
RewriteRule ^dev/(.*)$ $1
This would need to be in the root folder, or applied to the primary Apache configuration (not in .htaccess).
The usual rules about .htaccess redirects apply - including that RewriteEngine on
, Options FollowSymLinks
, and AllowOverride FileInfo
are included somewhere. Full details at http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With