I am developing a web app where people can create profiles. Their Profile is stored at: app/user/UserName. I want the URL to be like this: app/UserName but can't because I have already set the the url : app/CategoryName/StoryName where there are lots of Categories like Technology, Fashion, etc. Here's my htaccess content:
Options +FollowSymLinks
RewriteEngine on
ErrorDocument 404 /ef12/error/404.html
RewriteRule user/(.*)/ u.php?name=$1
RewriteRule user/(.*) u.php?name=$1
RewriteRule (.*)/(.*)/ scoop.php?cat=$1&title=$2
RewriteRule (.*)/(.*)开发者_StackOverflow scoop.php?cat=$1&title=$2
RewriteRule (.*)/ scoop.php?cat=$1
RewriteRule (.*) scoop.php?cat=$1
I want the User's Profile To Appear Like:
app/AbhishekBiswal
and stories to appear like:
app/technology/steve-jobs
I know it's possible: example > Twitter: twitter.com/Abhishek_Biswal and twitter.com/about where the former is a profile and the latter is a page about Twitter.
And Yes, I have also got Directories like Login and SignUp ( http://app/Login ), which also Conflicts with the Rules, that is, when I try to access Login directory, the server assumes Login as the UserName ( when I have set the profile url as http://app/UserName in htaccess ) and a "No Profile" Error is shown.
Thank You.
Add these lines before the rules. They prevent the rule from taking effect if a file or directory exist that match the URL:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
精彩评论