繁体   English   中英

重写在本地主机中不起作用的规则

[英]rewrite ruels not working in localhost

当我在线上传网站时,我试图重写我的网站的URL,一切正常,但在loaclhost中不起作用。 正在使用xampp> Windows7> Apach

链接无法按我重写的方式工作

例如,这将无法正常工作: http:// localhost / site / blog / id / 1

这在本地主机http://localhost/site/blog.php?id = 1中工作

RewriteRule ^([a-zA-Z0-9]+)$ $1.php [NC,L]

RewriteCond %{REQUEST_FILENAME} ^[A-Z]{3,}\s/+questions\.php\?postid=([^\s&]+) [NC]
RewriteRule ^ questions/postid/%1? [R=301,L]
#RewriteRule ^questions/postid/([^/]+)/?$ questions.php?postid=$1 [L,QSA]

您可以使用以下.htaccess:

RewriteEngine on
#"/questions.php?postid=123" to "/questions/postid/123"
RewriteCond %{THE_REQUEST} /questions\.php\?postid=([^\s&]+) [NC]
RewriteRule ^ /questions/postid/%1? [R=301,L]
RewriteRule ^questions/postid/([^/]+)/?$ /questions.php?postid=$1 [L,QSA]
#rewrite "file" to "file.php"
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ /$1.php [NC,L]

暂无
暂无

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

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