如何在php中将网址http://www.kreativemines.com/blogpost.php/?post_slug=search-engine-optimization更改为http://www.kreativemines.com/blog/search-engine-optimization。
我已经从.htaccess文件中使用此规则,但没有解决方案。
RewriteEngine On
RewriteRule ^blog/([a-zA-Z0-9_-]+)$ blogpost.php/?post_slug=$1
答案 0 :(得分:0)
这应该有效:
RewriteEngine On
RewriteCond %{THE_RERUEST} /blogpost\.php/\?post_slug=([^&\s]+) [NC]
RewriteRule ^ blog/%1? [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/([^/]+)/?$ /blogpost.php/?post_slug=$1 [QSA,L,NC]