dooper3 Posted February 3, 2007 Share Posted February 3, 2007 I am using mod_rewrite to change this: profiles.php?id=3 to this: profiles/3 by have a .htaccess file in the document root with the following code: RewriteRule ^profiles/([0-9]+) /profiles.php?id=$1 [QSA,L] It works fine, but it creates the problem that the PHP includes for the navigation, footer etc. then don't work as they are in a folder in the root directory called "includes", and the browser is trying to look in "profiles/includes" which of course doesn't exist (nor does the folder profiles, it's just created by the rewrite rule. Rather than going round all the pages and changing all the includes to the entire domain name and folder they need to link to etc, is there a quick fix that will work site wide? A rewrite rule would be brilliant, or any other method gratefully accepted! Thanks, Charlie Link to comment https://forums.phpfreaks.com/topic/36944-php-includes-trouble-with-mod_rewrite/ Share on other sites More sharing options...
Destruction Posted February 3, 2007 Share Posted February 3, 2007 Likely would be best using conditions to check if the files exist before the rewrite and only use the rule if they don't. This would be accomplished with this I believe: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^profiles/([0-9]+) /profiles.php?id=$1 [QSA,L] If it's PHP that the problem is occurring with using the include() statement this does not have anything to do with the browser so you'll need to check your include statements. Hope this helps, Dest Link to comment https://forums.phpfreaks.com/topic/36944-php-includes-trouble-with-mod_rewrite/#findComment-176371 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.