如何使用两个htaccess文件?

时间:2013-03-03 21:45:10

标签: php .htaccess

我有一个脚本用于从url中删除.php,第二个用于传递用户名

# activate rewrite engine
RewriteEngine On

# WordPress rules
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# username in url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /x/profile.php?username=$1

1 个答案:

答案 0 :(得分:1)

超级简单,将它们全部合并到一个文件中:

RewriteEngine On

# Combined rules
RewriteRule ^(.*)$ /x/profile.php?username=$1
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]