使用.htaccess清理URL

时间:2015-05-15 12:36:53

标签: .htaccess

来自:

crunchpaper.com/jlpt/form/try_question.php 

To This:

crunchpaper.com/jlpt/try_question/ 

我试试这个:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^try_question$ /try_question.php/$1 [NC,QSA]

但它不起作用。

我想清理上面的网址。

请帮帮我。感谢

2 个答案:

答案 0 :(得分:1)

此规则应该有效:

RewriteRule ^jlpt/form/try_question\.php$ jlpt/try_question/ [L] 

答案 1 :(得分:0)

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^jlpt/form/try_question\.php$ jlpt/try_question/ [L]

on /var/www/crunchpaper/jlpt


<Files ~ "^\.ht">
deny from all
</Files>
Options -Indexes

# ErrorPage
ErrorDocument 400 crunchpaper.com/
ErrorDocument 403 https://crunchpaper.com/
ErrorDocument 404 https://crunchpaper.com/
ErrorDocument 405 https://crunchpaper.com/


# DefaultPage
DirectoryIndex index.php index.html

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^crunchpaper.com\.com$
RewriteRule ^(.*)$ https://crunchpaper.com/$1 [R=301,L]

on /var/www/crunchpaper

Can you tell me what is wrong