Solved

mod_rewrite

Posted on 2006-06-08
21
312 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
  • 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Join & Write a Comment

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…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now