我正在编写一个htaccess文件,将我的网址重写为更漂亮的格式,以便;
你明白了......
我使用下面的代码找出并工作的那些人;
{item3, item3, item4} Leftovers: .1kg
{item2, item2, item2, item2, item4, item1} Leftovers: .6kg
# And keep listing all other outcomes under 14.1kg
但我想重写根URL,以便RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?home/$ index.php?page=1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?home$ index.php?page=1 [L]
直接进入domain.com/
,因为很明显,在进入网站时,页面变量将不会被传递,这就是适当的内容。
我当前的htaccess代码(不能正常工作)在下面;
domain.com/home
UPDATE 我现有的这个代码:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^$/ index.php?page=1 [L]
我无法使用此处第一个答案中提供的代码,因为我在尝试将两个变量传递给重写时遇到了问题 - 例如,某些页面包含RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?home/$ index.php?page=1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?home$ index.php?page=1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^$/ index.php?page=1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?about/$ index.php?page=2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?about$ about.php?page=2 [L]
Redirect 301 ^/?$ /home
等网址。
答案 0 :(得分:1)
尝试这样,看看它是否正常工作。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^$ index.php?page=1 [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(home|home/)$ index.php?page=1 [NC]
RewriteRule ^(about|about/)$ about.php?page=2 [NC]