我正在尝试转换:
http://localhost/mysite/blog.php?slug=post-by-paritosh
:
http://localhost/mysite/blog/post-by-paritosh
我使用。htaccess文件与以下规则
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?blog/(.*?)/?$ /blog.php?slug=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /blog.php?slug=([^& ]+)
RewriteRule ^/?blog.php$ /blog/%1? [L,R=301]
在http://www.htaccesscheck.com/上检查语法后,我发现它是好的,但重写没有像预期的那样工作。
您可以在tgconnectmediaservice/
目录下尝试这个。htaccess:
Options -MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} s/+(tgconnectmediaservice/blog).php?slug=([^&s]+)s [NC]
RewriteRule ^ /%1/%2? [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?blog/([^/]+)/?$ blog.php?slug=$1 [L,QSA,NC]