Mod Rewrite hiding extension conflict
I'm trying to figure something out.
This is the code I'm using to hide userpage.php?user=moonwalker and show localhost/moonwalker:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ userpage.php?user=$1 [NC,L]
RewriteRule ^([^/]+)/(images|videos|music)/?$ userpage.php?user=$1&page=$2 [NC,L]
</IfModule>
I also use it to load some pages like music, videos or images开发者_StackOverflow中文版. Now the problem: I'm trying to hide all .php extensions on my server. For example: search.php would change to localhost/search
But the script I just posted keeps thinking that search is a username, so it keeps showing me the userpage.php file.
Any idea how to solve this without changing the: localhost/username structure?
Thanks in advance.
Edit:
This is the second script I'm using to hide the extensions:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^select/([^/]*)$ /test/PDO/select2.php?lang=$1 [L]
</IfModule>
I found out that this is not possible. So I just changed my structure. Instead of localhost/username I use now localhost/user/username.
All problems are solved now.
精彩评论