开发者

htaccess to redirect index.php without parameter

开发者 https://www.devze.com 2023-04-06 21:37 出处:网络
I am looking for the Redirect for .htaccess: www.mydomain.com/A/ and www.mydomain.com/A/index.php without a parameter must be redirected to \"www.mydomain.com/B/\".

I am looking for the Redirect for .htaccess:

www.mydomain.com/A/ and www.mydomain.com/A/index.php without a parameter must be redirected to "www.mydomain.com/B/".

www.mydomain.com/A/index.php with a parameter like www.mydomain.com/A/in开发者_如何学Godex.php?id=123 is OK and must not be redirected.


You need to use mod_rewrite. You need to make sure that mod_rewrite is installed and enabled. Here is the rule for your URL:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^A/(index\.php)?$ http://www.mydomain.com/B/ [NC,R=301,L]

The rule will match both /A/ and /A/index.php and will only redirect if query string is empty.


I think you can use a redirect match for that

RedirectMatch "/A/index\.php$" http://www.mydomain.com/B
RedirectMatch "/A/$" http://www.mydomain.com/B
RedirectMatch "/A$" http://www.mydomain.com/B

I hope this will work :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号