?
Solved

mod_rewrite

Posted on 2006-06-08
21
Medium Priority
?
320 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
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 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