This is a discussion on .ht file within the Coding Help forums, part of the Webmaster Help category; Below is what i have in my .ht file, the first rewrite works fine but the second wont work at ...
| |||||||
| Register | Forum Rules | FAQ | Donate | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||||
| Below is what i have in my .ht file, the first rewrite works fine but the second wont work at all!, am i missing something? Code: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteRule ^news-([^/]*)\.htm$ /news.php?page=$1 [L] RewriteRule ^news-topic-([^/]*)\.htm$ /news_topic.php?topic=$1 [L] |
| |||||
| try adding NC as well after the L Code: Options +FollowSymlinks RewriteEngine On RewriteBase / #move this first RewriteRule ^news-topic-(.*)\.(htm|html|php)$ /news_topic.php?topic=$1 [L,NC] #above as it starts with the same ^news- RewriteRule ^news-([^/]*)\.(htm|html|php)$ /news.php?page=$1 [L,NC] #what do you expect here: -([^/]*) - numbers or letters? #if number you can try this: -([0-9]+) I will start the first one with "topic-news" and second to just "news"
__________________ :. Web Design & Development Web Design Ireland :. Search Engines Optimization Search Engines Optimization :. Directory Submission Directory Submission :. News & Press Release Ireland GiveItSocks.com :. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories :. I Have 2 Find It Directory SEF Directory Last edited by louie; 18-08-2007 at 01:44 PM. |
| |||||
| Quote:
|
| |||||
| no probs. you are welcome. |
| |||||
| louie, not sure if you can help me again, i have all the rule rewriting working and all now so i want to fancy it up a bit. This is what i have: Code: RewriteRule ^article/([^/]*)\.htm$ /news_topic.php?id=$1&title=$2 [L] news/title-of-news-article.htm But every news article is referenced by 'id' which is '$1', i dont want '$1' to show up in the links. And i need spaces rewritten as hypens. Any help appreciated. Thanks in advanced. |
| |||||
| unfortunately you need to pass the id as number in the string as you SQL query is based on that and not on the article name. Spaces and other characteres has to be changed inside the page while creating the a link. Easy done using preg-replace function PHP Code: Code: RewriteRule ^article/id([0-9]+)/([^/]*)\.htm$ /news_topic.php?id=$1&title=$2 [L,NC] |
| |||||
| Code: RewriteRule ^article/id([0-9]+)/([^/]*)\.htm$ /news_topic.php?id=$1&title=$2 [L,NC] Last edited by ziycon; 23-08-2007 at 12:51 AM. |
| |||||
| you could also ad the "id" to the href format on your page. |
| |||||
| I have the link formated like below: /article-news/1-title-of-news-article.htm '1' = article id 'title-of-news-article' = article title Last edited by ziycon; 23-08-2007 at 01:24 PM. |
| |||||
| something doesn't look right but if it's working like that and you are happy with it then leave it the way it is. |
| Tags |
| file |
| Thread Tools | |
| Display Modes | |
|
|
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Editing a table from a PDF file | oliflorence | Webmaster Discussion | 5 | 28-05-2007 10:22 PM |
| Wordpress rewriting htaccess file at random? | frankp | Coding Help | 5 | 21-04-2007 03:38 PM |
| PHP Include (Most Recent HTML File)? | ButtermilkJack | Coding Help | 6 | 29-03-2007 09:19 AM |
| Wordpress .htaccess file for no-www and mod-rewrite() | Cormac | Blogs & Blogging | 9 | 20-03-2007 09:31 AM |
| .pub file | bucks | General Chat | 5 | 27-01-2007 10:24 PM |
| ||||||||
| | ![]() | |||||||