Solved

.htaccess rewrite rules work seperately but not together?

Posted on 2013-05-14
6
267 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Title # Comments Views Activity
Navicat software trying to restore Mysql backup Connection lost 23 124
ProxyPass - Problem 5 189
apache and php 3 125
Change local server setting in php 6 96
As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

830 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