mathewjenkinson Posted April 26, 2009 Share Posted April 26, 2009 Is it possible to use mod_rewrite totally rewrite URLS that exist in the same folder? so: folder/index.php?id=110 comes out as: folder/education.php and folder/index.php?id=120 comes out as: folder/research.php Im assuming you would have to have a list in the .htacess file that references each file name, or is that rubbish? or could I use data from a mysql db to populate the name? So: folder/index.php?id=110 reads the title 'education' from the row in question and then fills that in as folder/education.php Link to comment https://forums.phpfreaks.com/topic/155749-mod_rewrite-directory-list/ Share on other sites More sharing options...
mathewjenkinson Posted April 27, 2009 Author Share Posted April 27, 2009 Ive had a go following some tutorials but I cant seem to get the url rewrite to work, can anyone have a quick look and help identify where ive gone wrong?: RewriteEngine on RewriteRule ^/?whatwedo\index.html$ index.php?id=100 [L] RewriteRule ^/?whatwedo\education.html$ whatwedo/index.php?id=110 [L] RewriteRule ^/?whatwedo\research.html$ whatwedo/index.php?id=120 [L] RewriteRule ^/?whatwedo\grants_awards.html$ whatwedo/index.php?id=130 [L] RewriteRule ^/?whatwedo\national_societies.html$ whatwedo/index.php?id=140 [L] RewriteRule ^/?whatwedo\newsletter.html$ whatwedo/index.php?id=150 [L] RewriteRule ^/?whatwedo\news.html$ whatwedo/index.php?id=160 [L] RewriteRule ^/?whatwedo\events.html$ whatwedo/index.php?id=170 [L] Thank you very much, Link to comment https://forums.phpfreaks.com/topic/155749-mod_rewrite-directory-list/#findComment-820159 Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 30, 2009 Share Posted April 30, 2009 Try this : Options +FollowSymLinks <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^whatwedo\/index\.html$ /index.php?id=100 [NC,L] RewriteRule ^whatwedo\/education\.html$ /index.php?id=110 [NC,L] ... </IfModule> The first / is always present in all URL and remove before rewriterule, don't include it in your regular expression. You need to escape both / (slash) and . (dot). And don't use that \ (backslash) as a separator for domainname/directory/file it's always this / (slash). And i added [NC] in the flag, mean no case (case insensitive). Link to comment https://forums.phpfreaks.com/topic/155749-mod_rewrite-directory-list/#findComment-823053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.