?
Solved

Help w/ mod rewrite rule - asp to php

Posted on 2008-02-10
8
Medium Priority
?
1,181 Views
Last Modified: 2012-06-22
Hi folks

recently converted a site from asp to php.  I'm keeping the same URL structure, which is like this:


index.php?id=page


I'd like a rewrite url that will simply take index.asp?id=page and send it to index.php?id=page.  "page" is just an example...whatever is after ".asp" should be put after ".php"


Thanks
0
Comment
Question by:bruno
  • 4
  • 3
8 Comments
 
LVL 6

Assisted Solution

by:paulp75
paulp75 earned 664 total points
ID: 20863897
try this in your .htaccess

RewriteEngine On
RewriteRule ^index.asp$ index.php
0
 
LVL 43

Assisted Solution

by:ravenpl
ravenpl earned 1336 total points
ID: 20865046
> whatever is after ".asp" should be put after ".php"

Options +FollowSymLinks
RewriteEngine On
RewriteRule (.*)\.asp$ $1.php [L,R=301]

#strip the R=301 is You don't want the user's browser bar be changed to *.php (so user will not know that You migrated to .php)
0
 
LVL 18

Author Comment

by:bruno
ID: 20866338
thanks both, I will try these later today.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
LVL 18

Author Comment

by:bruno
ID: 20866548
they both seem to be close, but neither one is working....

if my domain is example.com, this is what they are doing.


www.example.com/index.asp?id=page

will redirect to:


http://www.example.com/home/example/example.com/index.php?id=page


which is technically the full path on the server...but i can't have that redirect happening for the user....

they both seem to be doing the same thing.

thanks
0
 
LVL 18

Author Comment

by:bruno
ID: 20866849
Ok, I found if i do this it works ok:

RewriteRule (.*)\.asp$ /$1.php [L,R=301]


but i assume that would only work in the root directory?
0
 
LVL 43

Accepted Solution

by:
ravenpl earned 1336 total points
ID: 20867032
For some reason You have changed RewriteBase

Add
RewriteBase /
just after RewriteEngine On
0
 
LVL 18

Author Comment

by:bruno
ID: 20868413
Just a note, I haven't changed anything. This is a brand new hosting account....so that must be the way it was set up.

That seems to work though, thank you.
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20868450
> For some reason You have changed RewriteBase
It's my bad english. The default configuration sets RewriteBase to folder where .htaccess lives. It's changed on Your system.
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

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

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses

601 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