0

I have use the below htaccess script to purse url for my website:

RewriteEngine on

RewriteRule ^([A-Za-z0-9_-]+)/?$ index.php?con=$1 [L]

RewriteRule ^(administrator|admin)/([A-Za-z0-9_-]+)/?$ index.php?cms=$1&controller=$2 [L]

RewriteRule ^([A-Za-z0-9_-]+)/([^/]+)/?$ index.php?controller=$1&action=$2 [L]

RewriteRule ^(administrator|admin)/([A-Za-z0-9_-]+)/([^/]+)/?$ index.php?cms=$1&controller=$2&action=$3 [L]

I have url like:

http://example.com/search/country-name/

here:

controller = search;
action = country-name;

if the url is: http://example.com/admin/search/country-name/

then

cms = admin
controller = search;
action = country-name;

Now problem is I am unable to access my assets file ( css, js, image, etc files ). Becacue htaccess purse those below url also!

-> http://example.com/assets/css/style.css
or,
-> http://example.com/assets/js/style.css
or,
-> http://example.com/assets/image/image_name.jpg

What should i do so that htaccess do not purse the url http://example.com/assets/ and what ever in the assets folder ..

2 Answers 2

2

Add this after RewriteEngine on :

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

Like that, you avoid to rewrite real file or directory.

Sign up to request clarification or add additional context in comments.

2 Comments

Seems working, i need to test more to accept it... thank you for the solution.
Ok, and don't forget to use absolute links in your html code or to add <base href="/"> in your <head>.
1

Try to add

RewriteCond %{REQUEST_URI} !(css|js|fonts|images)

into your htaccess. (css/js/fonts/images) are the folder name

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.