r0b Posted May 13, 2011 Share Posted May 13, 2011 I'm currently using Options +FollowSymLinks Options +Indexes RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^([^\.]+)$ $1.php [NC,L] for changing urls from example.com/pagename.php to example.com/pagename I recently finished a CMS which has uses urls like example.com/?page=Pagename Could anyone help me with the htaccess code for chaning the example.com/?page=Pagename to just example.com/pagename Would something like this work? Options +FollowSymLinks Options +Indexes RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^([^\.]+)$ ?page=$1.php [NC,L] Quote Link to comment Share on other sites More sharing options...
r0b Posted May 13, 2011 Author Share Posted May 13, 2011 Seconds later I just think I figured it out, this works, is the code okay? Options +FollowSymLinks Options +Indexes RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^([^\.]+)$ ?page=$1 [NC,L] And am is this a valid looking htaccess file? (posting the whole htaccess) # more password protection <Files password> order allow,deny deny from all </Files> Options +FollowSymLinks Options +Indexes RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^([^\.]+)$ ?page=$1 [NC,L] Quote Link to comment Share on other sites More sharing options...
r0b Posted May 13, 2011 Author Share Posted May 13, 2011 The code works just fine, its causing one problem: When logging into the admin panel from a page for example example.com/Home trying to login to the administration panel to example.com/?login the link becomes example.com/Home?login. This problem doesn't occur if I login directly to the admin panel from example.com Quote Link to comment Share on other sites More sharing options...
r0b Posted May 13, 2011 Author Share Posted May 13, 2011 Solved this with three lines on the index.php $hostname = $_SERVER['PHP_SELF']; $hostname = str_replace('index.php', '', $hostname); $hostname = str_replace($page, '', $hostname); Cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.