Forum Moderators: phranque
I know there is a way to just change the .asp to php
... I did it manually til I hit 'The Wall'
Did i mention im not going to change ANY LINK besides the .asp extention to php
I was doing in the HTACCESS
RewriteRule ^Contact_Messages.asphttp://www.TheDomain.com/Contact_Messages.php[R=301]
Any pages without variables Bingo I was fine.
Then I hit the wall..
Riddle me this... How do i...
RewriteRule ^Ads_Logos.asp?Loc=North Carolinahttp://www.TheDomain.com/Ads_Logos.php?Loc=North Carolina[R=301]
When i put that in it's just a white screen.
I know there is a 3 line code that will just rewrite it. Is there a generator or is there away I can praise someone add add the thread to my delicious account. I've read the tutorials on every site and none make sense to me.
Im not writing them to www.TheDomain.com/North_Carolina_Ads_Logos.php Im leaving As is the client is well found so we are just going to leave well enough alone. Any help?
Thanks in advance. I know ALOT of people are confused when it comes to this type of function.. Well the noobs I talk too anyway.
RewriteRule ^area-we-can-fly-aerial-ads-to-banner-tow.asp?Location=http://www.aerialadsusa.com/area-we-can-fly-aerial-ads-to-banner-tow.php?Location=[R=301]
RewriteEngine on
RewriteRule ^([^.]+)\.asp$ /$1.php [L]
Using this nothing, including the links or URLs change from the front end. It stays exactly the same as it is now (or was yesterday :).
If you are having issues with the Query_String, you might need to use QUERY STRING APPEND:
RewriteRule ^([^.]+)\.asp$ /$1.php [QSA,L]
And I'm not sure if it's a typo or not, but you should have a space between the left side of your rule and the right... IOW: there should be a space before http: in your examples.
In the absence of any query string in the RewriteRule substitution, any query string attached to the originally-requested URL-path will be passed through the RewriteRule unchanged by default.
Jim
Would that work if i was on the www.RealDomain.com address
is there a temporary way to just make this rule work with:
[174.1xx.#*$!.#*$!...]
to rewrite it to
[174.1xx.#*$!.#*$!...]
?
[QSA] is only needed if the RewriteRule substitution contains a query string *and* you wish to *append* that new query-string to any existing query string which was attached to the originally-requested URL-path.In the absence of any query string in the RewriteRule substitution, any query string attached to the originally-requested URL-path will be passed through the RewriteRule unchanged by default.
Yeah, I added the second example, because I had one host where I had to use QSA when I shouldn't according to the book. I also remember copying and pasting working code here from the .htaccess file there and part of it was 'wrong' and wouldn't work when I changed hosts, but was the only way I could get it to work there. No clue as to why, but sometimes one host I had did some goofy stuff for me and I wanted to make sure I covered the question...
Would that work if i was on the www.RealDomain.com address.
Yes. To see an example, put up a /test/ directory on the website.
Create an .htaccess file in the test directory with the rule I gave you in it, but edit it to this:
RewriteRule ^([^.]+)\.asp$ /test/$1.php
Upload a file called test.php to the test directory.
Type example.com/test/test.asp into your browser.
You will see the results from test.php.
Switch back to the regular rule I gave you before going live.
I'm not sure about the development server question, because I use a real site on the same host as the site I'm working with most of the time for development, because I want to know how what I'm going to do actually functions at the host I'm using, so I code on a different site on the same server (or in a directory of the live site) rather than a 'development server'.
[edited by: jd01 at 5:58 pm (utc) on Oct. 3, 2009]
so your saying that i need to add the QSA into the [ ] or anything after the .asp?Location will be ignored..
No. You should not. I was explaining to Jim why I posted the second example. The first one *should* work, but in one case it did not for me and I had to use the second... You should Not need QSA.
Meaning sometimes i:
www.domain.com/about_us.asp
and sometimes
www.domain.com/about_us.asp?Loc=Georgia_branch
It will use the variable to sub in Georgia Branch into the text & meta tags.
... Thanks again.
So i cannot test this until I put the site live. I will launch and try. i'll just hope the google bot doesnt come. Monitor this thread if all hell breaks loose! I know you guys are great and much appreciated.
If you already have access to the new server, you should be able to try what I suggested with a test directory, or even in the root. I do not recommend testing it on the working site, even though I am confident it will work.
It should work on the IP address, because it's an internal rewrite...
So
RewriteRule ^([^.]+)\.asp$ [174.1xx.1xx.1x...] [L]
Now i dont have to even do a rewrite or change to .php.
You guys are great. I know what you mean now in the beginning of the thread about don't change anything. It masks. You guys are Excellant!
If the code jd01 posted doesn't work with or without "~ads/" in the RewriteRule pattern, try this instead:
RewriteRule ^([^.]+)\.asp$ /~ads/$1.php [L]
Jim