ILMV Posted April 25, 2009 Share Posted April 25, 2009 Hello! I need some help as I don't fully understand htaccess, When someone types in this address: http://mydomain.com/about I need to send the 'about' part like this: http://mydomain.com/index.php?page=about Can anyone help Many Thanks, ILMV Link to comment https://forums.phpfreaks.com/topic/155633-using-htaccess-for-cms/ Share on other sites More sharing options...
kevisazombie Posted April 26, 2009 Share Posted April 26, 2009 Here is a .htaccess I use for a web app. it remaps all incoming urls to the .index.php as path variable simillar to what you are trying. example: http://www.mydomain.com/category/test ends up as: http://www.mydomain.com/index.php?__page=category/test/ You will probably need to change the rules at the end around to be page instead of __page and maybe change up the images/css/js part ################################################### # Turn the RewriteEngine on. # ################################################### RewriteEngine on ################################################## # Properly rout for other web apps # ################################################# ################################################### # Do not process images or CSS files further # ################################################### # No more processing occurs if this rule is # # successful # ################################################### RewriteRule (images|css|scripts|js)/(.+)$ $1/$2 ################################################### # Add a trailing slash if needed # ################################################### # If this rule is used, the rewriting stops here # # and then restarts from the beginning with the # # new URL # ################################################### RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L] ################################################### # Rewrite web pages to the index page # ################################################### # No more processing occurs if any of these rules # # are successful # ################################################### #RewriteRule ^(.*)/?$ /index.php?__page=$1&%{QUERY_STRING} [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/?$ /index.php?__page=$1&%{QUERY_STRING} [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?__page=$1/$2&%{QUERY_STRING} [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /index.php?__page=$1/$2/$3&%{QUERY_STRING} [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?__page=$1/$2/$3/$4&%{QUERY_STRING} [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?__page=$1/$2/$3/$4/$5&%{QUERY_STRING} [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?__page=$1/$2/$3/$4/$5/$6&%{QUERY_STRING} [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?__page=$1/$2/$3/$4/$5/$6/$7&%{QUERY_STRING} [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?__page=$1/$2/$3/$4/$5/$6/$7/$8&%{QUERY_STRING} [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?__page=$1/$2/$3/$4/$5/$6/$7/$8/$9&%{QUERY_STRING} [L] Link to comment https://forums.phpfreaks.com/topic/155633-using-htaccess-for-cms/#findComment-819435 Share on other sites More sharing options...
ILMV Posted April 26, 2009 Author Share Posted April 26, 2009 Cheers kevisazombie! I am going to give it a go, I will return when I find out if it is successful ILMV Link to comment https://forums.phpfreaks.com/topic/155633-using-htaccess-for-cms/#findComment-819471 Share on other sites More sharing options...
ILMV Posted April 26, 2009 Author Share Posted April 26, 2009 Yes it worked very well! Many Thanks! Link to comment https://forums.phpfreaks.com/topic/155633-using-htaccess-for-cms/#findComment-819511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.