Solved

Get SCRIPT_NAME after mod_rewrite changes URL

Posted on 2003-11-06
3
289 Views
Last Modified: 2013-12-25
I am using mod_rewrite to optimize my site for better search engine placements without losing people going to my old pages.

For example, I am changing

http://www.mysite.com/cgi-bin/script.cgi?483&Experts 
to
http://www.mysite.com/483/Experts.html

I want my new URLS to be indexed by Google, and I want my old URLS to be un-indexed.

My plan was to

if SCRIPT_NAME contains cgi-bin{
   display <META NAME="GOOGLEBOT" CONTENT="NOINDEX, NOFOLLOW">
}

Unfortunately, no matter which URL I go to, SCRIPT_NAME has the value of cgi-bin/script.cgi, and not the 483/Experts.html.  Is there any way to get the actual URL the page is being viewed at?

Thanks.
0
Comment
Question by:Igiwwa
3 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 9697036
have a look at mod_env, in particular the SetEnv and PassEnv directives
0
 

Author Comment

by:Igiwwa
ID: 9704300
Thank you for your comment ahoffmann, but I'm afraid I do not understand how to use these commands in this context.  All the examples I found just showed how to use these commands to pass static variables to scripts.  Is there a way that I could use these commands to set a server variable if and only if mod_rewrite rewrote a page?
0
 
LVL 16

Accepted Solution

by:
_nn_ earned 250 total points
ID: 9748605
Never used it myself, but according to http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html#EnvVar you could use SCRIPT_URL or SCRIPT_URI instead of SCRIPT_NAME.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

863 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

22 Experts available now in Live!

Get 1:1 Help Now