Solved

Redirect 301 with http://%{SERVER_NAME}

Posted on 2010-08-30
3
360 Views
Last Modified: 2013-12-13
Hello,

I need to redirect one URL to another.  This is an easy task using:

Redirect 301  /sub1/sub2/ http://www.domain.com/sub45/sub46/

BUT i need to use the dynamic http://%{SERVER_NAME} and it is not working like this:


Redirect 301  /sub1/sub2/  http://%{SERVER_NAME}/sub45/sub46/

Thanks.


0
Comment
Question by:b1xx1b
  • 2
3 Comments
 

Author Comment

by:b1xx1b
ID: 33562908
HI

I actually came up with a solution to my problem but am not clear why this works.
Perhaps an expert can explain why it works?

RewriteRule ^/?sub1/sub2/$ /sub46/sub47 [R=301,NC,L]

I stumbled across this solution somewhere online - putting the ? in the old url path seemed to do the trick.
Why?
0
 
LVL 43

Accepted Solution

by:
ravenpl earned 500 total points
ID: 33564761
So You want the '?' explained?
If You put that RewriteRule in http.conf or included file. the leading / in match-string is required, if You put it into .htaccess file, the leading / in match-string is disallowed. The '?' makes it optional - it says it can be there, but it's fine if it's not. So this '?' makes the rule universal.

Of course simple Redirect hasn't worked, as the %{SERVER_NAME} is disallowed there.
0
 

Author Closing Comment

by:b1xx1b
ID: 33567873
great answer
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Echo images using file system 2 32
what is best version of php to use 6 46
Mysql sync between 3-4 mysql db 4 25
Intermittent Error on Page Loading 4 18
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now