[英]I need a htaccess RewriteRule for a simple pattern
我想要以下内容:
http://fref.co/anystring
改写为:
http://fref.co/?q=anystring
这是我走了多远:
RewriteEngine On
RewriteRule ^(.+)/?$ index.php?q=$1 [NC,L]
这应该可以满足您的需求:
Options +FollowSymLinks -MultiViews
RewriteEngine On
# Internally redirect http://fref.co/anystring to http://fref.co/?q=anystring
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ /index.php?q=$1 [L]
# Redirect http://fref.co/?q=anystring to http://fref.co/anystring
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(/index\.php|/)\?q=([^\s]+) [NC]
RewriteRule ^ /%2? [R=302,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.