I would like to redirect 301 to:
This is not so intricate for a single page, but I have:
... and so on
In other words I would like simply to remove a certain string, nomatter where it is placed, from all the possible links (thus I need a sort of wildcard or something similar with the PHP $_SERVER['PHP_SELF'], and I don't know how to build it) within my domain and redirect to the same links, but after removing that somestring_ in all of them
Any ideas, please?
Late note: Ok, I've seen that the anchors are not be seen by the server, thus in that case (#somestring) I had to use a PHP code. Still I wonder if Apache can perform a search/replace/rewrite job. is this possible? I've thought about something like:
RewriteRule ^(.+)sometring_(.+)$ $1$2
but for a reason or another it does not look to work... hm
Last edited by Kor; 10-15-2009 at 02:53 PM.
I think I got confused by the examples... are you trying to redirect any and everything that might contain a particular "somestring" to a new location or on a case by case basis? Both are possible with .htaccess, but which are you looking at?
Well, I've found a workaround (I am not so familiar with .htaccess, after all ).
To put it another words: I have 4 different domains, say maindomain, domain2, domain3 and domain4 on a virtual server. Physically, I have a single site, except for some includes which makes the four "indexes" slightly different and give different values to the document's title and meta tags for keywords, according to each of those domains.
Now, my boss wanted 2 extra things: To insert some keywords inside the menu's links, each domains with his own keyword, but when click on those links, the user should be 301 redirect to the correspondent maindomain's (in other words, to redirect 301 to a link from which I should remove that keyword.
Everything works under php/MySQL on Apache.
To simplify, let's take the case of the contact.php link. On those 4 domains, in their indexes, the links towards that contact page should look like:
Now, from no matter the domain's indexes, those links should redirect, all of them, to the unique file:
My solution so far (it works) is:
Thankfully I have only 12 pages to be linked from the menu, thus I wrote 12 code lines.
RewriteRule ^(.*)_contact http://maindomain/contact.php [R=301,L]
# and repeat the line for all the other menu's links (tariffs, skills...)
RewriteRule ^(.*)_tariffs http://maindomain/tariffs.php [R=301,L]
RewriteRule ^(.*)_skills http://maindomain/skills.php [R=301,L]
I was only wondering if I could have refined the code in a more dynamical way
Last edited by Kor; 10-19-2009 at 09:33 AM.
OK, but I would change the links in the menu also (assuming the change IS permanent)... or another option would be to pass the domain/keyword variable to the new "main" contact form so that you know where the request is coming from... http://maindomain/contact.php?domain2_keyword either from the menu or/and the .htaccess. (you can convert static urls to dynamic urls also).
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)