1

My .htaccess file looks as below

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)?$ /fm/page_new?location=$1&
r_id=$2&name=$3 [L]

Now, when i land on page_new (URL:http://localhost/fm/delhi/25/moods) via above rewrite then none of my css,js and img files are getting applied to page.

I googled it how to do it and i got below code

 # Allow any files or directories that exist to be displayed directly
 RewriteCond ${REQUEST_URI} ^.+$
 RewriteCond %{REQUEST_FILENAME}     
 \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d [OR]
 RewriteCond %{REQUEST_FILENAME} -l
 RewriteRule ^ - [L]

This also does not accomplish the goal as above rule allows .php access and i want to restrict same. However with above rewrite, css and js and img files also not getting applied.

Please help

1 Answer 1

1

This is probably because your links are relative URLS (looks like <img src="something.png"> vs <img src="/full/path/something.png">). So either change your links to absolute URLs or add a relative URI base to the header of your pages:

<base href="/fm/" />
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot... this saved my hell lots of time :) .. i actually dint want to change URLs to absolute... can u let me know if this tag is supported by all browsers?
@ Jon Lin ... When i rewrite URL as http://www.example.com/delhi1/23/moods then <base href="/" /> is not working and again css, js and img files distorted :(

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.