Solved

mod_rewrite

Posted on 2006-06-08
21
318 Views
Last Modified: 2010-03-04
I have no idea how to use mod_rewrite, but I'd like to rewrite my urls

From
www.oandcenterprises.com/index.php?privacy=1

to

www.oandcenterprises.com


I would like to do this for all my files.
0
Comment
Question by:carter_jl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 10
21 Comments
 
LVL 27

Expert Comment

by:caterham_www
ID: 16868148
> I would like to do this for all my files.

So no one can access subpages etc. if the queryString starts with privacy=1?

RewriteCond %{QUERY_STRING} ^privacy=1
RewriteRule \.php$ /? [R=301,L]
0
 

Author Comment

by:carter_jl
ID: 16871236
Thanks, Could you provide me with the steps to create my .htaccess file. I don't have a clue how to do this?
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16871325
is this just for looks?  wouldn't it be easier to just put all your pages in a frame?  
0
Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

Author Comment

by:carter_jl
ID: 16871569
This is just for looks, my site uses css.
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16871620
then just make a frame page like:

-- index.html---
<html>
<head>
<title>Page Title</title>
</head>

<frameset cols="*">
<frame src="index2.html">
</frameset>

</html>
0
 

Author Comment

by:carter_jl
ID: 16871662
I used css to escape from frames. I just need the .htaccess file in order to rewrite the url.
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16871677
is your server a linux or windows server?
0
 

Author Comment

by:carter_jl
ID: 16871746
linux
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16871800
i don't know how universal this is, but windows won't allow me to create a file ".htaccess", which would rule out the option of creating it in windows, editing it, and then transferring it to the server.

do you have ssh access to the server?
0
 

Author Comment

by:carter_jl
ID: 16871806
yes
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16871844
do you know how to use vi?
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16871915
i'll assume you know how to use some text editor...

login, cd to the root directory of the site, e.g.
cd /var/www/html

create the .htaccess file, e.g.
vi .htaccess

add the following text:
RewriteEngine    on
RewriteRule ^(.*)$ http://www.oandcenterprises.com

save the file.

that should work if apache is setup to allow htaccess files.
0
 

Author Comment

by:carter_jl
ID: 16871957
I'll try this solution when I get home.

Thanks
0
 

Author Comment

by:carter_jl
ID: 16879566
This solution did not work, it only took me back to the www.oandcenterprises.com directory.
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16879629
try it with

RewriteRule ^(.*)$ http://www.oandcenterprises.com [R=301,L]
0
 

Author Comment

by:carter_jl
ID: 16881226
When I use this now I get

http://www.oandcenterprises.com/?services=1

which is usually www.oandcenterprises.com/index.php?services=1


This is almost close because now I just need www.oandcenterprises.com and for it to go to the appropriate page
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16885720
i'm not exactly a mod_rewrite expert, but i'll give it one more try.

RewriteRule ^(.*)$ http://www.oandcenterprises.com/? [R=301,L]

0
 

Author Comment

by:carter_jl
ID: 16911432
Thanks for all your help philjones85, but this solution did not work either.

I was reading somewhere that if your images using relative locations that mod_rewrite would not work?

Do you know if this is true?
0
 
LVL 6

Accepted Solution

by:
philjones85 earned 500 total points
ID: 16913012
it makes sense that it wouldn't since mod_rewrite is directing you to a new url independent of your current location, though i can't say that i know for sure that they don't have a way around it.

sorry i couln't be of more help...
0
 

Author Comment

by:carter_jl
ID: 16914007
Just for your efforts, ill award you the points.
0
 
LVL 6

Expert Comment

by:philjones85
ID: 16915792
thanks
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

Suggested Solutions

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 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