[英]another .htaccess url rewriting issue
我在wampserver上有一个正在本地开发的站点,并且在.htaccess文件中使用URL重写。 我已经尝试了以下所有方法:
这是我的.htaccess文件,它在此目录中(“ C:\\ wamp \\ www \\ pascale3”)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(about|mission|contact)/?$ index.php?p=$1
</IfModule>
这是我要重写的网址:
http://local.pascale3.com/?p=about
我也有一个Godaddy直播网站,在那也不行
试试这个index.php进行调试
<?php
echo('<pre>');
print_r($_SERVER);
print_r($_GET);
die;
转到http://local.pascale3.com/contact时,看看是否有类似的东西
Array(
......
[QUERY_STRING] => p=contact
[REQUEST_URI] => /contact
[SCRIPT_NAME] => /index.php
[PHP_SELF] => /index.php
[argv] => Array
(
[0] => p=contact
)
[argc] => 1
)
Array
(
[p] => contact
)
如果没有看到该p参数,则说明服务器配置/ htaccess存在问题。 还要检查index.php?p = contact是否可以正常工作。 您会看到上面的调试信息。
将您的.htaccess规则替换为以下代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# to externally redirect /index.php?p=about to /about
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(?:index\.php)?\?p=(about|mission|contact)[&\s] [NC]
RewriteRule ^ /%1? [R=301,L]
# to internally forward /about to /index.php?p=about
RewriteRule ^(about|mission|contact)/?$ /index.php?p=$1 [L,QSA,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.