|
#41
|
|||
|
|||
|
Mod rewrite cannot change your urls for you. You'll have to program that.
The rewrite happens on the server when you rewrite /product-name/01.htm to index.php?product_id=01 |
|
#42
|
|||
|
|||
|
Hi, Mike, I'm desperate ... sorry for this wordy question.
![]() I had to restructure my wordpress site (DOH!) and I'm finding it really hard to enter redirects because of how modrewrite interacts with them. I think the problem modrewrite statement is: RewriteRule ^(.+)/([^/]+)(/[0-9]+)?/?$ /index.php?category_name=$1&name=$2&page=$3 [QSA,L] This is necessary to run my wordpress site with "permalinks", but it makes it (apparently) impossible to redirect like this: Redirect /2005/12/30/widget-ideas/ http://www.domain.com/themes/themes2/widget-ideas/ ... which mod-rewrite turns into this problem: http://www.domain.com/themes/themes2...et-ideas&page= Is there some way I can rewrite this statement to take advantage of the fact that all my old URLs would have numbers and none of my new ones would ... without screwing up how this statement "runs" my current permalinks? (Thinking hard ... hmm.. .but it IS possible the new ones would occasionally have a number if it showed up on the post title, like "5 ways to wash a car" ... that makes it even harder. Or sometimes posts have titles like "trends for 2006." This is tough) Last edited by blakekr : 05-07-2006 at 01:24 PM. |
|
#43
|
|||
|
|||
|
Do all your oldd urls follow the same date pattern? and do all your theme folders stay named the same? If so this would work with the redirect from old to new.
Code:
# redirect /2005/12/30/widget-ideas/ ---> /themes/themes2/widget-ideas/ RewriteRule ^[0-9]+/[0-9]+/[0-9]+/([^/]+)/?$ http://www.yourdomain.com/themes/themes2/$1/ [R=301,L] |
|
#44
|
|||
|
|||
|
Hyphens in URL
Hi SEO Mike,
Thanks for your valuable inputs on the URL rewriting phenomenon. I haven't had success in my research on my questions and on my other posts to make a final decision. I'm hoping you can help me. First of all thanks for your time here's my question... We know from Google via Matt Cutts that hyphens are the preferred delimiters in URLs For example www.widgets.com/bright-new-widgets .....is better than.... www.widgets.com/bright_new_widgets .....or..... www.widgets.com/bright+new+widgets For URL rewriting, with .htaccess rewrite rules we can only have a limited number of hyphens. What other character can also be used in this case? As an example: www.widgets.com/news-about-bright-new-widgets In the above example, since the "news-about" is another variable it needs to be delimited with another character to separate it from "bright-new-widgets" Is using "plus"(+) an option? www.widgets.com/news-about+bright-new-widgets Or is there another character which can be used to seperate two words? I have seen many posts on similar questions asked, but no concrete answers. I will be choosing double dashes (--) or (+) as my last resort. I could make another directory like: www.widgets.com/news-about/bright-new-widgets but I prefer not to as I think a flat directory structure is more effective. Any ideas? |
|
#45
|
|||
|
|||
|
Hello!
I had used to have a site at domain1.com. There were many files in www.domain1.com/files/ directory. There are in other sites and other places links to files in that folder. This site has moved to domain2.com, keeping the old directory structure intact. domain1.com is now used by another site also mine. ( apache2 ) What i want to do is redirect every direct link to www.domain1.com/files/FILE.ZIP (for example) to www.domain2.com/files/FILE.ZIP (this is where the file really is!) What .htaccess file should i put in /files directory in domain1.com ? Thank you! |
|
#46
|
|||
|
|||
|
Quote:
I would suggest this url for the above example /news-about/bright-new-widgets.htm 1 folder deep allows you a lot more control over you rewrite rules. /news-about/bright-new-widgets = /news-about/bright-new-widgets/index.. and is probably farther than you'd want to be from your root level pages. The hard thing about doing root level rewrites is making them unique from other files so that normal files don't get pushed through the rewrite rule and mess up your static pages. I hope that makes sense. You can use + ~ ^ and other meta characters to put into the url to be a unique identifier between variables. but all that can get messy. Let me know if that answered your questions. And definitely let me know if you need help on the rules |
|
#47
|
|||
|
|||
|
Quote:
You could probably get away with doing a simple frame hack. on domain1.com/files/FILE.ZIP rewrite it to a static html page on your site that just calls the zip from a frame src. The only thing is, I don't know if that would prompt a download I would put the url in a frame src and test it to see if it prompts for a download. If it does I'll help you write the rule that will get it all going ![]() |
|
#48
|
|||
|
|||
|
When to remove 301 redirects?
hi mike,
We have recently followed your advice with apache module rewrite, we could see that when we used [NC,L] (in the .htaccess - RewriteRule) the IE keeps the "abc.html" url address in the address bar & when we use [R=301,L] the IE puts "product.do?p=a&n=b&d=c" in the address bar so, we obviously wish that the address bar display "abc.html". so when can we return [NC,L] another thing we're afraid is that we configured it wrongly since when I type "abc.html" I receive in the reponse header 301 status code with an indication that "product.do?p=a&n=b&d=c" is the permamnent URL. can you please help - we're afraid to loose SE rank for misconfiguration Our apache .htaccess is RewriteEngine on RewriteBase / RewriteRule ^products_([^-]+)-([^-]+)-([^-]+)-([^.]+).html$ ProductsAction.do?topicName=$1&categoryName=$2&pag eNum=$3&productsOnPage=$4 [R=301,L] our site is: babysupply . info BR Luk |
|
#49
|
|||
|
|||
|
The R=301 is telling the server to issue a 301 redirect vs being an alias.
All you need to have is [L] as a flag declaring it's the last rule and you'll be good. Code:
RewriteRule ^products_([^-]+)-([^-]+)-([^-]+)-([^.]+).html$ ProductsAction.do?topicName=$1&categoryName=$2&pageNum=$3&productsOnPage=$4 [L] |
|
#50
|
|||
|
|||
|
thanks,
althuogh I will still have to indicate to the SE that all ".do" requests are permanently rediected to ".html" I followed your advice from previous post although I must have something wrong (in .htaccess or some httpd.conf flag which I forgot) RewriteRule ^products_([^-]+)-([^-]+)-([^-]+)-([^.]+).html$ ProductsAction.do?topicName=$1&categoryName=$2&pag eNum=$3&productsOnPage=$4 RewriteCond %{REQUEST_URI} ^.*ProductsAction\.do$ RewriteCond %{QUERY_STRING} ^topicName\=([^&]+)\&categoryName\=([^&]+)\&pageNum\=([^&]+)\&productsOnPage\=([^&]+)$ RewriteRule ^.*$ products_%1-%2-%3-%4.html [R=301,L] My biggest fear is to lose rank if I'll not redirect BR Luk |
|
#51
|
|||
|
|||
|
Created a Loop
hi all,
I think I am misusing module rewrite, I would like to place code which convert static URL to Dynamic (I am placing it in .htaccess) RewriteEngine on RewriteBase / RewriteRule ^foo\.html$ /date.jsp [L] I would like to place another code snippet which coverts dynamic URL to static (I place it in httpd.conf) RewriteCond %{REQUEST_URI} ^/date\.jsp$ RewriteRule ^.*$ foo.html [R=301,L] This causes an infinite loop. How can I solve this chicken egg dillema? |
|
#52
|
|||
|
|||
|
@SeoMike
Very helpful this article!
i have some problems with portuguese/latin characters such ç â ã, etc. I mean, with this rewriterule bellow: RewriteRule ^article/([0-9]+)/([_A-Za-z0-9-+).html index.php?action=file&fileid=$1 [L] will change to http://www.mysite.com/article/47/aço.html but when i click the link, the browser shows: http://www.mysite.com/article/47/a%C3%A7o.html And i get error page, don't load properly If i replace RewriteRule ^article/([0-9]+)/([^ç]).html it will load the page, but i stiil have the url with "a%C3%A7o.html" since browsers does not accept "ç". Anyways, google will index a page with "ç" or "ã"? if not, how can i change it to replace "ç" to "c" and show "aco.html"? Is it possible? i need to change also: á, é, í ,ó, ú to a, e, i, o, u â, ê, ô to a, e, o ã, õ to a, o. thanks in advance! |
|
#53
|
||||
|
||||
|
You should not use special characters - I am from Denmark and we have 3 of them too
Just drop them and you'll be fine - or convert them "phonetically". In Danish I convert ø to oe æ to ae and å to aa - and even Google recognises this as proper conversions. |
|
#54
|
|||
|
|||
|
Mod_Rewite
Hi,
Can anyone help me? I'm new to mod_rewrite. Need to do this: 1) domain redirect - this is working in httpsd.conf for apache server. 2) Need to rewrite any old domain names with "pagename=Singalong" to new server name "pagename=ImadeIt" example: http://test.busy.ca/servlet/ContentS...Singalong/Home to http://test.MadeIT.ca/servlet/Conten...e=ImadeIt/Home There are many more URLs that needs to be rewrite base on pagename. I'm at my wits end. How can i do this? ![]() |
|
#55
|
|||
|
|||
|
Quote:
![]() |
|
#56
|
|||
|
|||
|
Help with php url rewrite
Hi,
I hope some one may be able to help. I see in this thread the talk is similar to what I need to do some work on. Basically I have this code below in my inludes.php what I am trying to do is rewrite the php code for friendly urls. $Categories .= "<tr>\n\t<td bgcolor=#ECECEC><a class=BlackLinkB href=\"search.php?c=$ai[CategoryID]\">$ai[CategoryName]</a></td>\n</tr>\n"; This php code above bringsup a dynamic nav bar to navigate my site. I know I need to change the bits in between the "" but I am not sure what I can change it to. I also need to find out the rewrite code to put in the htaccess file I am toatlly new to all of this and would love some help here please from some one. Sincerly, Toni |
|
#57
|
|||
|
|||
|
Mod Rewite - CAN YOU HELP ME?
Dear all,
I am trying to create some code that does the following: somefile.someextension BECOMES somefile_someextension.php5 When I specify the file extension to be converted it works fine: RewriteRule ^(.*)\.inten $1_inten.php5 But of course I want to set it up so that any file extension is converted. Can anyone help? Cau, lumpy |
|
#58
|
|||
|
|||
|
How to replace ../ with /
Hi, I have seen some of the html code where
<img src='/images/abc.gif'> and <img src='../images/abc.gif'> produce the same result (there is no 'images' folder duplication, only one images folder exist), I believe that this trick can be done by using mod_rewrite (replace / with ../) right ? But how ? Can someone show me how to achieve this? It would save me hours of digging to the html page and changing the source folder. thanks |
|
#59
|
|||
|
|||
|
Hi all ! Please help Newbie
Hi Everybody
My link http://mysite/cafenhe/cafe.php change to http://mysite/cafenhe/cafe.html and http://mysite/cafenhe/cafe.php?a=1 change to http://mysite/cafenhe/cafe/1.html Everybody can help me. I'm newbie to use MOD ReWrite. Regards. |
|
#60
|
|||
|
|||
|
>> somefile.someextension BECOMES somefile_someextension.php5 <<
>> When I specify the file extension to be converted it works fine: << >> RewriteRule ^(.*)\.inten $1_inten.php5 << I would caution against using underscores in URLs. Use hyphens or dots instead. The rule you need is: RewriteRule ^(.*)\.(.*) $1_$2.php5 |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|