[solved]Can htaccess rewrite links in a page?

Problems with the Linux version of XAMPP, questions, comments, and anything related.

[solved]Can htaccess rewrite links in a page?

Postby mikey » 04. November 2011 19:16

Hi,

I would be most appreciative if somebody could advise me if it is possible to "rewrite urls that appear within the content of webpages" to Search Engine Friendly Format using .htaccess rewrite rules? (I can only find examples online to rewrite the url that will display in the address bar of the user's browser for the page that is about to be handed to the browser.)

I look forward to your response.

Kind Regards,
Mikey
mikey
 
Posts: 5
Joined: 03. July 2008 15:59

Re: Can htaccess rewrite links in a page?

Postby Altrea » 04. November 2011 21:01

Hi,

can you give an example of what you want to have?

Old URL: ...
New URL ...
And how your folder structure on your server would look like?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Can htaccess rewrite links in a page?

Postby mikey » 05. November 2011 14:39

Altrea wrote:Hi,

can you give an example of what you want to have?

Old URL: ...
New URL ...
And how your folder structure on your server would look like?



Hi,

Thank you for responding.

Here is the information that you requested:

Old url would be:
http://www.websitename.com/index.php?output=product&productid=3217&categorypath=111_142&page=4

output=product means that a product and it's associated information is being displayed.

productid=3217 is the product id for product called "yellow golf shirt".

categorypath=111_142 consists of two categories. Category 111 is the parent category called "clothing". Category 142 is the child category called "men".

New Url would be:
http://www.websitename.com/product/3217/category/111/142/page/4/clothing/men/yellow-golf-shirt.html

or it could be like this:

New Url would be:
http://www.websitename.com/product-3217/category-111-142/page-4/clothing/men/yellow-golf-shirt.html

Question:
The New format of the url must replace the old url format of all links that appear in the content of a web page. Is it possible to rewrite all instances of urls in the body content of a website page using .htaccess rules?

In my research I have come across "mod_rewrite", "mod_proxy_html", "mod_substitute", and "mod_sed". I honestly do not know what is the best or only option to rewrite the urls that appear in the content of a web page.

I look forward to your response.

Kind Regards,
Mike
mikey
 
Posts: 5
Joined: 03. July 2008 15:59

Re: Can htaccess rewrite links in a page?

Postby JonB » 05. November 2011 15:37

the answer is no.
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Can htaccess rewrite links in a page?

Postby Altrea » 05. November 2011 18:18

mod_rewrite can't/don't change any source codes.
It can just analyse the requested url and reroutes it to a different if a rule matches.

If you want to change urls in existent web pages, then you need a scripting language like php, javascript, or something similar.
If you use a vendor script (like a CMS or Framework) then there is maybe a plugin to do this for you.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Can htaccess rewrite links in a page?

Postby mikey » 08. November 2011 09:58

Altrea wrote:mod_rewrite can't/don't change any source codes.
It can just analyse the requested url and reroutes it to a different if a rule matches.

If you want to change urls in existent web pages, then you need a scripting language like php, javascript, or something similar.
If you use a vendor script (like a CMS or Framework) then there is maybe a plugin to do this for you.


Hi,

Thank you so much for your effort in answering my question so effectively and efficiently. I now have a much better sense of direction.

Kind regards,
Mike
mikey
 
Posts: 5
Joined: 03. July 2008 15:59

Re: Can htaccess rewrite links in a page?

Postby Altrea » 08. November 2011 11:24

Thanks for your feedback.
You are very welcome 8)

Now i can close the topic
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 22 guests