我的网址就像:
但我想要一个像seo友好的网址:
我在我的httaccess中使用了以下网址RewriteRule,但它无法正常工作
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ mock_profile.php?user_name=Yasin
RewriteRule ^([a-zA-Z0-9_-]+)/$ mock_profile.php?user_name=Yasin
## Below is my all httacess code ##
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [nc]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
#RewriteRule ^(.*).html$ $1.php [QSA]
RewriteCond %{THE_REQUEST} \ /(.+)\.php
RewriteRule ^ /%1.html [NC,L,R=301]
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)/?$ mock_profile.php?user_name=$1
答案 0 :(得分:1)
试试这个:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)/?$ mock_profile.php?user_name=$1 [L]
阐释:
以下条件告诉服务器如果请求是针对现有目录,则停止重写。
RewriteCond %{REQUEST_FILENAME} !-d
如果请求是针对有效文件,则告诉服务器停止重写:
RewriteCond %{REQUEST_FILENAME} !-f
如果请求不是文件/目录,则重写它:
RewriteRule ^([a-zA-Z0-9_-]+)/?$ mock_profile.php?user_name=$1