Hi, I am building a website and decided to try and add clean URL's using mod_rewrite. This is my first time using mod_rewrite so i decided to follow a guide which resulted in URL's such as www.example.com/gallery/12. This URL would then be rewritten to index.php/gallery/12.

The problem I am having is that using a URL such as www.example.com/home will correctly go to the index.php page and everything loads as expected, using www.example.com/home/12 however breaks any relative url on the page including css/images etc.

the code i used for mod_rewrite:

RewriteEngine On
RewriteBase /paper/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

I am not sure if this is the best way to do it but I would like to be able to add any number of variables to the end of the URL. I was originally going to to create a base path variable and the add this to the start of links etc, but the site uses a CMS and any additional images added through it would have the same problem.

can anyone suggest a better way of achieving this?

Recommended Answers

All 2 Replies

try changing the paths to either ./ or define the exact path by defining the sites url

Member Avatar for diafol

Can you make the internal links absolute?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.