Mobile app version of vmapp.org
Login or Join
Shelley277

: Htaccess Redirect everything to index.php little trouble I need to redirect everything (www.example.com/, www.example.com/en/, www.example.com/en/index.php?do=xyz, etc.) to index.php, but I can't get

@Shelley277

Posted in: #Htaccess #Redirects

I need to redirect everything (www.example.com/, example.com/en/, example.com/en/index.php?do=xyz, etc.) to index.php, but I can't get everything working.

1st try:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /index.php?path= [NC,L,QSA]


works, but stylesheets href="css/xyz.css" don't load if I use example.com/en/. I would need to change them to href="/css/xyz.css" and I won't.

2nd try:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]{2})/(.*) [QSA]
RewriteRule ^([^/]*)$ index.php?op= [L,NS,QSA]


This works, CSS files are ok, the only bad thing is that jquery $.get can't find the files so I think I am missing something on the way.
And maybe I could do everything using only one RewriteRule?

Any suggestion?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Shelley277

1 Comments

Sorted by latest first Latest Oldest Best

 

@Shakeerah822

After some trys and searches I got it working using:

RewriteCond %{DOCUMENT_ROOT}/ -f [OR]
RewriteCond %{DOCUMENT_ROOT}/ -d
RewriteRule ^([a-z]{2})/(.+)$ / [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme