Reputation: 5411
I have the following code on my .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]
this allow me to have the following URL's:
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
But I need two things:
1) have the root on pepperscope.com instead of pepperscope.com/cp/index.php
2) remove the cp folder from all my links, like that:
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
Thanks in advance for your help.
Upvotes: 1
Views: 35
Reputation: 1521
You just need to remove the cp after ^
, so something like this.
Remove all cp folders from all links
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]
To fix the problem with the root, best thing I can come up with is this
RewriteRule ^([/]?)$ cp/index.php
Upvotes: 1