我的.htaccess
上有以下代码RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cp/artes-escenicas/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^cp/ciencia-y-tecnologia/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^cp/arte-y-diseno/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^cp/deportes/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^cp/idiomas/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^cp/academico/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^cp/rutas/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^cp/voluntariado/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
这允许我拥有以下网址:
http://pepperscope.com/cp/index.php
http://pepperscope.com/cp/artes-escenicas
http://pepperscope.com/cp/ciencia-y-tecnologia
http://pepperscope.com/cp/arte-y-diseno
http://pepperscope.com/cp/arte-y-diseno
http://pepperscope.com/cp/deportes
http://pepperscope.com/cp/campamentos
http://pepperscope.com/cp/idiomas
http://pepperscope.com/cp/academico
http://pepperscope.com/cp/rutas
http://pepperscope.com/cp/voluntariado
http://pepperscope.com/cp/lifestyle
但我需要两件事:
1)在pepperscope.com上使用root而不是pepperscope.com/cp/index.php
2)从我的所有链接中删除cp文件夹,如:
http://pepperscope.com/artes-escenicas
http://pepperscope.com/ciencia-y-tecnologia
http://pepperscope.com/arte-y-diseno
http://pepperscope.com/arte-y-diseno
http://pepperscope.com/deportes
http://pepperscope.com/campamentos
http://pepperscope.com/idiomas
http://pepperscope.com/academico
http://pepperscope.com/rutas
http://pepperscope.com/voluntariado
http://pepperscope.com/lifestyle
提前感谢您的帮助。
答案 0 :(得分:1)
你只需要在^
之后删除cp,就像这样。
从所有链接中删除所有cp文件夹
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^artes-escenicas/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^ciencia-y-tecnologia/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^arte-y-diseno/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^deportes/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^idiomas/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^academico/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^rutas/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
RewriteRule ^voluntariado/([^/]+)/?$ cp/course-details.php?name=$1 [NC,L]
要解决root的问题,我能想出的最好的事情是
RewriteRule ^([/]?)$ cp/index.php