繁体   English   中英

302 htaccess从旧的php页面重定向到新的url

[英]302 htaccess redirect from old php page to new url

假设我有一个旧网址http://abc.com/x.php?a=xyz&b=jkl我需要将所有请求都重定向到具有查询字符串或不具有http://xyz.com的页面x.php。 /X/

以下是.htaccess文件,该文件位于http://xyz.com的根目录中

# Turn on URL rewriting
RewriteEngine On

RewriteBase /

# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $0 !=server-status


# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

在文档根目录的htaccess文件中,添加以下规则:

RewriteEngine On
RewriteRule ^/?x.php$ /x/? [L,R=302]

请注意,如果您有规则将/x/改写 /x.php ,则这两个规则将发生冲突并导致内部循环。 您可以通过以下方式防止循环:

RewriteCond %{ENV:REDIRECT_STATUS} !200

就在上面的RewriteRule上方。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM