1

我对 .htaccess 了解不多,而且我在 .htaccess 中的正则表达式概念上苦苦挣扎。

我想要与 facebook 上相同的 url 概念作为用户个人资料,但破折号(-),下划线(_),点(。)我想要在 url 中也是目前我的 url 规则如下:

RewriteRule ^([a-z,\_,A-Z,\_,\-,0-9.][!pagenotfound|home|abuse/*|user/*|start/*|login/*|account/*|message/*|find/*|cms/*|accountactivation/*|register/*]*)/?$  memberspersonalinfo.php?members=$1 [QSA]

这种模式有一些错误

但是当在我的浏览器中 domain.com/username 正在运行时,它工作正常但是当 url或者domain.com/test-test它重定向到 `PAGE NOT FOUND PAGEtest_testtest.test

并且在我定义为遵循该规则的 .htaccess 规则中,例如 abuse/* 在我使用星号的任何地方都有动态 ID (*),它们引用的是动态值。什么时候我会做规则

RewriteRule ^([a-z,\_,A-Z,\_,\-,0-9.]*)/?$  memberspersonalinfo.php?members=$1 [QSA]

它工作正常,但是当我移至主页时,memberspersonalinfo.php它会自行调用页面。

我试图用 htaccess 脚本再次解释我的问题

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
DirectoryIndex  index.html index.php

ErrorDocument 404 /pagenotfound
ErrorDocument 403 /pagenotfound
ErrorDocument 401 /slapme/pagenotfound
ErrorDocument 500 /pagenotfound

#index
RewriteRule ^index.html$  index.php [L]
RewriteRule ^index$  index.php [L]
RewriteRule ^home$  index.php [L]

#nopage
RewriteRule ^pagenotfound$  nopage.php [L]

#Regitration
RewriteRule ^register/createaccount$  userregistration.php [L]

#Regitration Confirmation
RewriteRule ^register/accountconfirmation$  registrationconfirm.php [L]

#Activation Regitration
RewriteRule ^accountactivation/([a-z,\_,A-Z,\_,\-,0-9]*)/([a-z,\_,A-Z,=,\_,\-,0-9]*)$ registrationactivation.php?UsercontactID=$1&AccountId=$2 [L]

#after login
RewriteRule ^user/main$  after_login.php [L]

#Payment Detail
RewriteRule ^user/myaccount$  useraccount.php [L]

#Logout
RewriteRule ^user/logout$  logoutuser.php [L]

#creategroup
RewriteRule ^start/creategroup$  http://domain.com/start/creategroup [L,R=301]

#Forgot Password
RewriteRule ^user/forgotpassword$  http://domain.com/user/forgotpassword [L,R=301]

#Login
RewriteRule ^login/userlogin$  http://domain.com/login/userlogin [L,R=301]

#Remove account
RewriteRule ^account/remove$  removeuseraccount.php [L]

#Send an email page
RewriteRule ^message/?$  contacttouser.php [L,QSA]

#Report any site user page
RewriteRule ^abuse/([0-9]*)/$  reportsiteuser.php?reportUserID=$1 [L,QSA]

#CMS FIND FRIENDS PAGE
RewriteRule ^find/friend$  http://domain.com/find/friend [L,R=301]

#CMS TERMS OF USE PAGE
RewriteRule ^cms/howitworks$  howitworks.php [L]

#CMS CREATE OWN SLAP PAGE
RewriteRule ^cms/createownslap$  createownslap.php [L]

#CMS BRAND OR PRODUCT PAGE
RewriteRule ^cms/brandorproduct$  brandorproduct.php [L]

#CMS APPS AND FEATURES PAGE
RewriteRule ^cms/appsandfeatures$  appsandfeatures.php [L]

这是我完整的 htaccess 代码,一切正常,所有规则都在工作,但是当我添加时

#group personal profile page page
RewriteCond %{REQUEST_URI} !/abuse(.*)
RewriteCond %{REQUEST_URI} !/user(.*)
RewriteCond %{REQUEST_URI} !/start(.*)
RewriteCond %{REQUEST_URI} !/login(.*)
RewriteCond %{REQUEST_URI} !/account(.*)
RewriteCond %{REQUEST_URI} !/message(.*)
RewriteCond %{REQUEST_URI} !/find(.*)
RewriteCond %{REQUEST_URI} !/cms(.*)
RewriteCond %{REQUEST_URI} !/accountactivation(.*)
RewriteCond %{REQUEST_URI} !/register(.*)
RewriteCond %{REQUEST_URI} !/social(.*)
RewriteCond %{REQUEST_URI} !/images(.*)
RewriteCond %{REQUEST_URI} !/css(.*)
RewriteCond %{REQUEST_URI} !/js(.*)
RewriteCond %{REQUEST_URI} !/userimages(.*)
RewriteRule ^([a-z,\_,A-Z,\_,\-,0-9.]+)/?$  memberspersonalinfo.php?members=$1 [QSA,L]

它总是加载 memberspersonalinfo.php

4

0 回答 0