Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

mod_rewrite

Posted on 2006-06-08
21
Medium Priority
?
321 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

604 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