【发布时间】:2021-02-14 08:55:07
【问题描述】:
我最近在我现有的 http://localhost/mysite PHP 网站的子文件夹(博客)中添加了 WordPress,我已经为 &_GETS 请求重写了 URL,当我输入 http://localhost/mysite/ 时,WordPress 网站工作正常blog/ 但是当我输入 http://localhost/mysite/blog 它仍然有效但 URI 更改为 http://localhost/mysite/blog/?id=blog 。任何帮助将不胜感激。
总之
我想要 http://localhost/mysite/blog
变成 http://localhost/mysite/blog/ 使用 .htaccess
但它会自动更改为 http://localhost/mysite/blog/?id=blog
.htaccess
RewriteEngine on
##Rewrite for downloading page##
RewriteRule ^download/([0-9]+) /mysite/download.php?file=$1 [NC]
RewriteRule ^downloadpdf/([0-9]+) downloadpdf.php?file=$1 [NC]
#For sitemap.xml
RewriteRule ^sitemap.xml sitemap.php [NC]
#This section is for forms url rewriting for course
RewriteRule ^([^/.]+)$ index.php/?id=$1 [NC]
RewriteRule ^([^/.]+)/([^/.]+)$ index.php/?id=$1&course=$2 [NC]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)$ index.php/?id=$1&course=$2&stream=$3 [NC]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)$ index.php/?id=$1&course=$2&stream=$3&subject=$4 [NC]
#Custom pages pretty URL's
RewriteRule ^about-us about-us.php [NC]
RewriteCond %{QUERY_STRING} ^id=read$ [NC]
RewriteRule ^([^/.]+)$ read/index.php [NC,L,R=301]
ErrorDocument 404 /mysite/errors/not-found.php
【问题讨论】:
-
你需要设置永久链接
-
欢迎来到 SO,请在您的问题中分享您尝试过的 htaccess 文件,谢谢。
标签: wordpress apache .htaccess