Forum Moderators: phranque

Message Too Old, No Replies

Joomla Htacces Url Rewriting

Joomla htaccess url rewriting for dynamic to static webpages.

         

skerobics

11:54 am on Apr 17, 2012 (gmt 0)

10+ Year Member



Hello I have a website with dynamic urls as follows.

http://www.example.net/index.php?option=com_content&view=article&id=8&Itemid=161

I want to change the dynamic website to

http://www.example.net/redhat-system-administration-rh124.html

I applied the following code but my website was not working. Can you give me the correct code as well as wehre i am going wrong.

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?(id=8&)?itemid=161\ HTTP/
RewriteRule ^index\.php$ http://www.example.net/redhat-system-administration-rh124.html? [R=301,L]
RewriteRule ^redhat-system-administration-rh124.html$ /index.php?option=com_content&view=article&id=8&Itemid=161 [L]

Thank you for your help in advance.

[edited by: bill at 12:50 am (utc) on Apr 18, 2012]
[edit reason] turned off smilies [/edit]

phranque

7:53 pm on Apr 17, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



when you request
http://www.example.net/redhat-system-administration-rh124.html
or
http://www.example.net/index.php?option=com_content&view=article&id=8&Itemid=161
what responses do you get?

you're missing the "option=com_content&view=article&" part of the query string in your RewriteCond.

skerobics

3:29 pm on Apr 19, 2012 (gmt 0)

10+ Year Member



hey thanks for your reply. Can you give me exact code,
thanks for helping.

lucy24

6:29 pm on Apr 19, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can you give me exact code

No. There are Forums that will do that, but we don't.

Incidentally, why not leave off the .html extension as long as you're rewriting? Paw through the last page or so of posts in this forum.

g1smd

2:18 pm on Apr 23, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What you put in the rule patterns has to match what URL is being requested. If your code has anchors, or includes static items such as index.php or \ HTTP these effectively constrain the pattern such that it nows says the URL begins or ends with a particular thing. If the requested URL does't begin or end with that thing, the rule pattern will not match.

Look again at your question and then your example code. The "\ HTTP" part appears too early. Your example URL has more parameters.

skerobics

9:00 am on Apr 27, 2012 (gmt 0)

10+ Year Member



Hello g1smd, i tried with different parametres also but somewhere i am missing exact code. Can someone help me with this please.

Thanks in advance,

David.

lucy24

5:38 pm on Apr 27, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In your original post:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?(id=8&)?itemid=161\ HTTP/

I'd break this into two pieces:

... {THE_REQUEST} \?
and
... {QUERY_STRING} itemid=161

The first piece verifies that the query string was part of the original request, so you're not rewriting in circles. The second piece looks only as the specific part of the query that you're interested in. Unless your code is set up so query strings always come in exactly the same order, it's safer to look for each piece separately.

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?(id=8&)?itemid=161\ HTTP/
RewriteRule ^index\.php$ http://www.example.net/redhat-system-administration-rh124.html? [R=301,L]
RewriteRule ^redhat-system-administration-rh124.html$ /index.php?option=com_content&view=article&id=8&Itemid=161 [L]

It may seem trivial, but leave a blank line after each Rule so you can tell at a glance which pieces go together. Otherwise it's easy to start thinking a Condition goes with two or more consecutive Rules, which of course it can never do.

### Preview insists on showing smileys even though I know perfectly well they've been disabled!

phranque

8:58 pm on Apr 27, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i tried with different parametres also but somewhere i am missing exact code. Can someone help me with this please.

nobody can help you unless you describe the current status of your rewrite configuration, the request you made and the response provided by the server.