Jump to content

Recommended Posts

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]

 

Link to comment
https://forums.phpfreaks.com/topic/236299-nice-urls-not-working/
Share on other sites

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]

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.