Forum Moderators: phranque
I have been trying with absolutely no success to change some dynamic URL's to static URL's by using mod_rewrite.
Dont know how this would affect anything but I currently have this in my .htaccess so I can use some SSI's on regular .html pages, for including link tables, common footer etc:
Options Indexes FollowSymLinks Includes
AddType application/x-httpd-cgi .cgi
AddType text/x-server-parsed-html .html .htm
------------------------------------------------------
I am trying to change this and other dynamic URL to a static URL mainly for the SE's and getting some hard to index links indexed.
I want to change this type link:
*ww.example.com/bass-reports/index.php?action=showentries&catid=4
to something like this:
*ww.example.com/bass-reports/showentries/4.html or how ever it works out.
I have tried this with nada results.
RewriteEngine On
RewriteRule ^/(.*)/(.*).html /index.php?action=$1&catid=$2
I have tried many ways. I have tried putting htaccess in the sites root. I have put the htaccess in the dircetory where the webpages are. I don't know if I am missing something in the htaccess or what.
the only thing I know for sure is I am outside my area of knowledge and any help would be great.
Am I even on the right track?
Thank You, Joe Dodd
[edited by: jdMorgan at 6:35 pm (utc) on May 12, 2005]
[edit reason] Removed specifics. [/edit]
Welcome to WebmasterWorld!
URL-paths as seen by RewriteRule in .htaccess are stripped of their leading slash, so your rule would never match. Tips: Using ".*" multiple times in a pattern is very inefficient. Literal periods in patterns need to be escaped by preceding them with "\". Use the [L] flag unless you have a reason not to.
I'd suggest:
RewriteRule ^([^/]+)/([^.]+)\.html$ /index.php?action=$1&catid=$2 [L]
RewriteRule ^bass-reports/([^/]+)/([^.]+)\.html$ /bass-reports/index.php?action=$1&catid=$2 [L]
Now if you request the static URL, mod_rewite will pass control to index.php with the two query string parameters.
Jim
So there should be no problems there.
I even tried the same concept with this link at my other site-- no luck. Same result as the original links in the first post.
*ww.example.com/business/search_result.php?search=Browse&category=Fishing+Charters
Is there something I am missing in my .htaccess file? My code didn't work nor yours so that leads me to believe that I may be forgetting something in the htaccess file.
I appreciate any help, I'd like to try one more time.
I've tried the apache site with no luck.
Thanks Joe
[edited by: jdMorgan at 6:33 pm (utc) on May 12, 2005]
[edit reason] No specific URLs, please. [/edit]
You might try adding QSA to your directives: (I have to do this some times, even when I don't think I should.)
RewriteRule ^([^/]+)/([^.]+)\.html$ /index.php?action=$1&catid=$2 [QSA,L]
RewriteRule ^bass-reports/([^/]+)/([^.]+)\.html$ /bass-reports/index.php?action=$1&catid=$2 [QSA,L]
Justin
** Thinking this had already been covered, I left it out of the original... Where do your pages link to? It almost looks as though you are going backward. IOW do the links on your page that a user would click go to the static or dynamic URL?
Here is the original exact link a user clicks. Untouched and unaltered. I changed the first w to * so it would show as a link.
*ww.fishingreporters.com/bass-reports/index.php?action=showentries&catid=1
On the apache page they had instructions for going from a static URL to a dynamic URL but I don't know why one would want to do that.
[httpd.apache.org...]
[httpd.apache.org...]
We will see what happens.
Thank You
Start here:
[webmasterworld.com...]
Justin
Are you also saying that if I take this link:
*ww.example.com/business/search_result.php?search=Browse&category=Fishing+Charters
the link created by the .php script and use it as a hard link on say my home page for example then I can change the look of the link with mod_rewrite?
From what I gather the link must be an actual 'hard link' that a user clicks before you can use mod_rewrite to change it in the way I was looking to do.
Otherwise I am lost and will read the other thread fully.
Most forums make it sound so easy - ie change your dynamic links to search engine friendly links. That makes one think you can use mod_rewrite to alter the link as it is created by the php script.
Told you I was lost. Also told you I was outside my knowledge on this stuff.
Is there a way to change the dynamic or database link to a SE friendly link?
Thanks, Joe
The simplest way to do what you are attempting is to link to the html page/address you would like to have displayed. (The page this link goes to does not exist, except in the browser.) Then you can use mod_rewrite to serve the contents of your php page to the URL appearing in the browser.
Please, note with mod_rewrite there are only two ways to have a URL appear in a browser: 1. The URL is requested, either through a link, or actually typed in to the address bar. 2. To externally redirect to the URL. EG 301 or 302 Redirect, that will show the new location in the browser.
I think reading the other thread would be very helpful for you.
Justin