我已经尝试了在 stackoverflow 上发布的大量解决方案,但似乎没有什么对我有用。我想重写我网站上的一些 URL 以使其对搜索引擎友好。
我想要这样的 URL:- http://www.mysite.com/index.php?filter=accounts 显示为:- http://www.mysite.com/accounts
网络上的许多帖子都将其作为解决方案:-
RewriteRule ^([^/]+)/?$ index.php?filter=$1 [QSA,L]
但这无济于事。
我的站点是一个 Joomla CMS 站点,并且已经在 .htaccess 文件中进行了一些重写。难道是我把我的新 RewriteRule 放错了地方?
这是未添加我的新 RewriteRule 的完整 .htaccess 文件
Options +FollowSymLinks
RewriteEngine On
# prevents people from accessing anything with phpMyAdmin
RewriteRule phpMyAdmin - [F]
# force canonical www if request is for non-www or has port number etc
RewriteCond %{HTTP_HOST} !^(www\.mysite\.com)?$
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteBase /
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
任何帮助将非常感激。:-)