Mod rewrite 重写规则以使url用户友好
我有两条规则。 第一个允许不带.php扩展名的请求 第二个重写所有以/account/(.*)$to/account.php开头的请求?action=$1 帐户规则怎么了?为什么它会错过资源路径 这是我的规则Mod rewrite 重写规则以使url用户友好,mod-rewrite,url-rewriting,rewrite,Mod Rewrite,Url Rewriting,Rewrite,我有两条规则。 第一个允许不带.php扩展名的请求 第二个重写所有以/account/(.*)$to/account.php开头的请求?action=$1 帐户规则怎么了?为什么它会错过资源路径 这是我的规则 RewriteEngine on RewriteRule ^/?account/(.*)$ /account.php?action=$1 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\
RewriteEngine on
RewriteRule ^/?account/(.*)$ /account.php?action=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
将代码替换为以下内容:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^account/(images/.*)$ /$1 [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^account/(.*)$ /account.php?action=$1 [L,QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php [L]
请确保您的图像、js和css文件路径是绝对路径,即它们以斜杠或
http://
开头。我无法更改图像路径。图像的当前URL是什么?这不是完整的URL。是http://example.com/images/image.png
还是别的什么?另外,请告诉我您的文档根是什么,account.php在文档根中的位置是什么?我的文档根是/home/ddd/public\u html。图像位于/home/ddd/public\u html/images下。account.php位于文档\u根目录下