Jump to content

Recommended Posts

I have started to write a website from scratch and would like to know how to use mod_rewrite in order to shorten urls.

I want to shorten http://f.marktest.co.uk/index.php?page=about

to:

http://f.marktest.co.uk/about

I have tried several methods but was unable to find anything that worked.

Link to comment
https://forums.phpfreaks.com/topic/284336-wwwcomindexphppageabout-to-wwwcomabout/
Share on other sites

You will need to recode your links to the new url format, eg

<a href="http://site.com/about">About Us</a>

Then you can apply the following in an .htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1
Edited by Ch0cu3r
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.