自定义.htaccess网址

时间:2016-09-17 00:47:21

标签: php .htaccess mod-rewrite

下面的代码工作正常

旧代码

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
#####exclude /cp folder####
RewriteCond %{REQUEST_URI} !^/cp
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php  
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /((?!cp)[^.]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [NC,L,QSA,R=301]


RewriteRule ^singer/(.*)$ singer.php?s=$1 [NC,L,QSA]
RewriteRule ^album/(.*)$ album.php?a=$1 [NC,L,QSA]
RewriteRule ^lyric/(.*)$ lyric.php?l=$1 [NC,L,QSA]
RewriteRule ^singers/(.*)$ singers.php?p=$1 [NC,L,QSA]
RewriteRule ^album/(.*)$ album.php?a=$1 [NC,L,QSA]

http://example.com/album.php?a=11 http://example.com/album/11

我想用PHP考试将其编辑为GET变量

http://example.com/album/year/2016 http://example.com/album.php?y=2016

所以我对这段代码

RewriteRule ^album/([0-9]+)$ album.php?a=$1 [NC,L,QSA]
RewriteRule ^album/year/([0-9]+)$ album.php?y=$1 [NC,L,QSA] 

我看到内部服务器错误 此外,尝试使用ErrorDocument处理请求时遇到500内部服务器错误错误。根据要求

http://example.com/album/year/2016http://example.com/album/20

在所有页面中正常工作

新代码

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
#####exclude /cp folder####
RewriteCond %{REQUEST_URI} !^/cp
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /((?!cp)[^.]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [NC,L,QSA,R=301]

RewriteRule ^singer/(.*)$ singer.php?s=$1 [NC,L,QSA]
RewriteRule ^album/([0-9]+)$ album.php?a=$1 [NC,L,QSA]
RewriteRule ^album/year/([0-9]+)$ album.php?y=$1 [NC,L,QSA]
RewriteRule ^lyric/(.*)$ lyric.php?l=$1 [NC,L,QSA]
RewriteRule ^singers/(.*)$ singers.php?p=$1 [NC,L,QSA]

现在我评论这一行7#RewriteRule ^(.*)$ $1.php我的代码工作正常,不让变量停止工作

http://example.com/singers http://example.com/about

1 个答案:

答案 0 :(得分:0)

尝试将<BorderPane> <top> <fx:include source="header.fxml"/> </top> <left> <fx:include source="sidebar.fxml"/> </left> <center> <!-- ... --> </center> </BorderPane> 更改为

^(.*)$ $1.php