Jump to content

Recommended Posts

Hi Guys

 

I am new to .htaccess and I am trying to shorten the URL from something like

 

http://79.170.44.125/platinumbrides.co.uk/page.php?page_id=about_us

 

to

 

http://79.170.44.125/platinumbrides.co.uk/about_us

 

Looking through tutorials out there I have the htaccess as

 

RewriteEngine On

 

RewriteRule ^([a-zA-Z0-9_-]+)$ page.php?page_id=$1

RewriteRule ^([a-zA-Z0-9_-]+)/$ page.php?page_id=$1

 

However this is not working it still shows the original url and if I type inthe shortened URL I get an error saying the page cannot be displayed

 

What am I doing wrong? :confused:

 

 

Link to comment
https://forums.phpfreaks.com/topic/192484-shortening-urls/
Share on other sites

I always find that when debugging, adding the [R] flag to the end of rules can help you see why it isn't working. You don't appear to be specifying a RewriteBase, as such you should probably change your pattern to...

 

RewriteRule ^([a-zA-Z0-9_-]+)/?$ /page.php?page_id=$1

 

The key difference is the forward slash before the second URI. Note I also combined the two RewriteRules by simply saying the trailing slash is optional.

Link to comment
https://forums.phpfreaks.com/topic/192484-shortening-urls/#findComment-1014253
Share on other sites

Looking at your original code it would appear that the IP is your domain meaning platinumbrides.co.uk is a folder on the domain. Which means you need to change the relative paths of your domains, in that case you're probably going to need something more like...

 

RewriteRule ^platinumbrides\.co\.uk/([a-zA-Z0-9_-]+)/?$ /platinumbrides.co.uk/page.php?page_id=$1

Link to comment
https://forums.phpfreaks.com/topic/192484-shortening-urls/#findComment-1014277
Share on other sites

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.