Solved

.htaccess rewrite rules work seperately but not together?

Posted on 2013-05-14
6
266 Views
Last Modified: 2013-05-14
I have a couple of rules in my .htaccess file that work OK on their own but not together?
If I comment one out the other works and vise versa?

Your feedback would be appreciated.


http://www.mywebsite.com.au/241/Services/Services.html

RewriteRule ([0-9]+)(.*)\.html$ index.php?page_id=$1

http://www.mywebsite.com.au/index.php?page_id=241



http://www.mywebsite.com.au/item_details/1147/Web-Design.html

RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?page=$1&id=$2&new_page_title=$3 [L]

http://www.mywebsite.com.au/index.php?page=item_details&id=1147&new_page_title=Web-Design

Open in new window

0
Comment
Question by:sabecs
  • 3
  • 3
6 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39165431
You need a RewriteCond for which Rule applies.
0
 

Author Comment

by:sabecs
ID: 39165455
Thanks GaryC123, but how/where do I add that?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39165487
I'm not sure what it is you are trying to do?
You are rewriting seo friendly urls to non friendly?
What condition should be there for the two rewrites?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:sabecs
ID: 39165514
The URL displayed in browser is

http://www.mywebsite.com.au/241/Services/Services.html

I then rewrite it to get the page_id of 241 and pass it to my PHP page which extract content from my MySQL table based on this page id.

I hope that makes sense?
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39165593
I'm guessing item_detail is the deciding factor

RewriteCond %{REQUEST_URI} item_details
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?page=$1&id=$2&new_page_title=$3 [L]
RewriteRule ([0-9]+)(.*)\.html$ index.php?page_id=$1

Open in new window

0
 

Author Closing Comment

by:sabecs
ID: 39165748
Thanks Gary, that works perfectly....Cheers..  Andredw
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question