View Full Version : Simple rewrite rules from php to html pages
blogmaster2003
04-12-2006, 03:51 PM
Hi
I need someone help me with this:
I have several pages ending .php
I need to rewrite them to end in .html
I also need to change the name of the url: example:
curently i have: www.domain.com/2345.php
2345.php has a <title> and i want it looks like:
www.domain.com/title.html
I know i have to put some code in .htacess file, but i tried to read, read, read and canīt get nothing :(
Thank you for your reading this.
blogmaster2003
04-14-2006, 12:41 AM
hmm
nobody?
nothing?
:rolleyes:
Hi,
Can I ask first, so you have any php coding in the existing files or are they just straight html?
If they are straight html, you can use something like this in your htaccess:
Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [L]
Don't forget though, rewriting your urls is a major step that shouldn't be taken lightly. Static files with php extensions will rank just as well as html documents, in my experience.
Cheers,
Paz.
blogmaster2003
04-14-2006, 02:07 AM
hmmm
You are right.
I expressed bad and i think i canīt have them like html.
I need to get the urls insted of
domain.com/12345.php
to
domain.com/title-of-the-123456.php
??
Thank you.
Haha, well maybe I wasn't thinking straight either, but as I understand it you can also use htaccess to parse html files as though they were php files. I'm not sure if you can combine url rewriting and parsing at the same time though.
Also I'm not sure if what you want to do is worth the trouble. It's nice to have keywords in the url, but the disruption it will cause to your site may make it unproductive.
Anyway here we go:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !^/some-title.*
RewriteRule ^(.*)$ /some-title$1
Cheers,
Paz.
blogmaster2003
04-18-2006, 11:31 AM
Thank you Paz. It worked ok.
This is the subject about seo/servers/languages i dontīreally understand almost nothing, you gave me a big help, thank you very much.
guybrush
04-20-2006, 06:28 AM
hi paz
Will greatly appreciate your help in the following:
i have this url:
http://www.xyz.com/article.php?title=this_is_the_article_title
what should do to make it look like this:
http://www.xyz.com/news/this_is_the_article_title
Hi Guybrush,
Are you sure you really want to do this? Yahoo and Google are getting quite good at indexing dynamic urls, especially if you only have one variable.
If the pages are indexed already I wouldn't bother.
But if you must, you can try this:
Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^news/(.*)\.html$ article.php?title=$1 [L]
I've added an .html for you, but you can change it to .htm as nec
If you don't want either then you should be able to delete the \.html bit; but I've never tested that. Let me know how you get on.
Cheers,
Paz.
guybrush
04-20-2006, 10:21 AM
Advice accepted and the rewrite idea dropped. :)
By the way, the site aint in operation yet so no harm wouldve been done. Actually its a news site and felt that the "article.php" in the url could be misleading.
many many thanks.
[QUOTE=guybrush]Advice accepted and the rewrite idea dropped. :)
By the way, the site aint in operation yet so no harm wouldve been done. Actually its a news site and felt that the "article.php" in the url could be misleading.
many many thanks.[/QUOTE]
haha well sorry for any confusion, but if it's a new site then I'd go for it! It's a simple enough mod, and I always thing static htmls look more attractive in the serps listings.
Cheers,
Paz.
vBulletin v3.0.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.