我在重写网站中的 href 时遇到问题.首先,我设法从 na URL 中删除了所有 .php 扩展名,然后我添加了将所有 mydomain/img?id=X 重写为 mydomain/img/X,但我一直在为另一件事而苦苦挣扎一段时间我将不胜感激任何帮助.我的网站由许多页面组成,页码 X 的链接是 mydomain/?page=X(例如 mydomain/?page=3),但我想将该 URL 重写为 mydomain/page/X
I have a problem with rewriting hrefs in my website. First of all I managed to remove all .php extensions from na URLs, then I added rewriting all mydomain/img?id=X to mydomain/img/X, but I have been struggling with one more thing for some time and I would appreciate any help. My website consists of many pages and the link to page number X is mydomain/?page=X (e.g mydomain/?page=3), but I want to rewrite that URLs to mydomain/page/X
这是我的 .htaccess:
Here is my .htaccess:
RewriteEngine on RewriteBase / <something not important> RewriteCond %{HTTP_HOST}//s%{HTTPS} ^www\.(.*)//((s)on|s.*)$ [NC] RewriteRule ^ http%3://%1%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^img/([0-9]+)/?$ img.php?id=$1 RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php 推荐答案就在这条规则的下方:
RewriteCond %{HTTP_HOST}//s%{HTTPS} ^www\.(.*)//((s)on|s.*)$ [NC] RewriteRule ^ http%3://%1%{REQUEST_URI} [L,R=301]尝试添加:
RewriteCond %{THE_REQUEST} \ /+\?page=([0-9]+) RewriteRule ^ /page/%1? [L,R] RewriteRule ^page/([0-9]+)/?$ /?page=$1 [L]更多推荐
在 index.php 中重写
发布评论