I'm using .htaccess to remove index.php from the URL and use its parameters with a / (slash).
For example, before:
example.com/index.php?id=posts
after:
example.com/posts
I'm also using .htaccess to allow / (slash) in the parameters like: example.com/posts/mypost, where posts / mypost is an index.php parameter!
But my problem is that when I access the parameter with a / (slash) like: example.com/posts/mypost it loads the page but without loading the CSS, it only works if I use without the / as in example.com/posts or just a string with no bars! But if I DELETE this part of the .htaccess code:
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
The parameter with / slash works, however using index.php?Id= like: example.com/index.php?id=posts/mypost. But it's not what I want, I want to remove the index.php and use the parameters of him with / slash!
My .htaccess complete code:
#remove index.php
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
#use parameters without " ?id= "
RewriteEngine on
RewriteRule ^/?index.php$ - [L,NC]
RewriteRule ^([a-zA-Z0-9.]+)?$ index.php?id=$1 [QSA,L]
#allow " / " slash
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule (.*) index.php?id=$1 [L,NS]