Solved

mod_rewrite

Posted on 2006-06-08
21
319 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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 …
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

707 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