Apache Htaccess冲突某些url不工作

Apache Htaccess冲突某些url不工作,apache,.htaccess,mod-rewrite,friendly-url,Apache,.htaccess,Mod Rewrite,Friendly Url,我有这个htaccess文件现在的问题是…我想。。。。 我还希望twekr.com/login.php是twekr.com/login 但只有一条规则适用于以下行。。。profile.php规则有效或login.php规则有效。。。。htaccess文件中是否有错误 Options +MultiViews -MultiViews -Indexes RewriteEngine On <IfModule mod_expires.c> ExpiresActive On Expir

我有这个htaccess文件现在的问题是…我想。。。。 我还希望twekr.com/login.php是twekr.com/login 但只有一条规则适用于以下行。。。profile.php规则有效或login.php规则有效。。。。htaccess文件中是否有错误

 Options +MultiViews -MultiViews -Indexes
 RewriteEngine On
 <IfModule mod_expires.c>
 ExpiresActive On
 ExpiresByType image/jpg "access 1 year"
 ExpiresByType image/jpeg "access 1 year"
 ExpiresByType image/gif "access 1 year"
 ExpiresByType image/png "access 1 year"
 ExpiresByType text/css "access 1 month"
 ExpiresByType text/html "access 1 month"
 ExpiresByType application/pdf "access 1 month"
 ExpiresByType text/x-javascript "access 1 month"
 ExpiresByType application/x-shockwave-flash "access 1 month"
 ExpiresByType image/x-icon "access 1 year"
 ExpiresDefault "access 1 month"
 </IfModule>
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^([^\.]+)$ $1.php [NC,L]

 RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?user=$1
 RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?user=$1
 errorDocument 400 http://www.twekr.com/oops.php?400
 errorDocument 401 http://www.twekr.com/oops.php?401
 errorDocument 404 http://www.twekr.com/oops.php?404
 errorDocument 500 http://www.twekr.com/oops.php?500
 RewriteRule ^post/([a-zA-Z0-9_-]+)$ post.php?id=$1
 RewriteRule ^post/([a-zA-Z0-9_-]+)/$ post.php?id=$1
 RewriteRule ^read/([a-zA-Z0-9_-]+)$ read.php?id=$1
 RewriteRule ^read/([a-zA-Z0-9_-]+)/$ read.php?id=$1
 <ifModule mod_gzip.c>
 mod_gzip_on Yes
 mod_gzip_dechunk Yes
 mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
 mod_gzip_item_include handler ^cgi-script$
 mod_gzip_item_include mime ^text/.*
 mod_gzip_item_include mime ^application/x-javascript.*
 mod_gzip_item_exclude mime ^image/.*
 mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
 </ifModule>
选项+多视图-多视图-索引
重新启动发动机
过期于
过期按类型映像/jpg“访问1年”
过期按类型图像/jpeg“访问1年”
ExpiresByType image/gif“访问1年”
过期按类型图像/png“访问1年”
ExpiresByType文本/css“访问1个月”
ExpiresByType text/html“访问1个月”
过期按类型应用程序/pdf“访问1个月”
ExpiresByType文本/x-javascript“访问1个月”
过期按类型应用程序/x-shockwave-flash“访问1个月”
过期按类型图像/x图标“访问1年”
ExpiresDefault“访问1个月”
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^([^\.]+)$$1.php[NC,L]
重写规则^([a-zA-Z0-9_-]+)$profile.php?用户=$1
重写规则^([a-zA-Z0-9_-]+)/$profile.php?用户=$1
错误文档400http://www.twekr.com/oops.php?400
错误文档401http://www.twekr.com/oops.php?401
错误文档404http://www.twekr.com/oops.php?404
错误文档500http://www.twekr.com/oops.php?500
重写规则^post/([a-zA-Z0-9_-]+)$post.php?id=$1
重写规则^post/([a-zA-Z0-9_-]+)/$post.php?id=$1
重写规则^read/([a-zA-Z0-9_-]+)$read.php?id=$1
重写规则^read/([a-zA-Z0-9_-]+)/$read.php?id=$1
mod_gzip_on Yes
是的
mod|gzip|item|u include file.(html?| txt | css | js | php | pl)$
mod_gzip_item_包含处理程序^cgi脚本$
mod_gzip_项目包括mime^text/*
mod_gzip_item_包括mime^application/x-javascript*
mod_gzip_项_排除mime^image/*
mod_gzip_item_排除rspheader^内容编码:.*gzip*

如果您使用类似于:
http://twekr.com/user/aniket
http://twekr.com/profile/aniket
因为如果将来有一个名为
的用户登录
,可能会引起麻烦

如果您确定不会有任何用户名与服务器上现有的
php
文件冲突,则可以使用以下代码:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /profile\.php\?user=([^&\s]+) [NC]
RewriteRule ^profile\.php$ /%1? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
# Use the following if there is only login.php
# RewriteRule ^login/?$ /login.php [NC,L]
# Use following to rewrite all php files to be extensionless
RewriteRule ^.*$ $0.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /profiles.php?user=$0 [QSA,L]

如果您同意关于使用
http://twekr.com/user/aniket
作为URL结构;那么规则将是:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /profile\.php\?user=([^&\s]+) [NC]
RewriteRule ^profile\.php$ /user/%1? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^user/(.+)$ /profiles.php?user=$1 [NC,QSA,L]