mod_rewrite

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.
carter_jlAsked:
Who is Participating?
 
philjones85Connect With a Mentor Commented:
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
 
caterham_wwwCommented:
> 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
 
carter_jlAuthor Commented:
Thanks, Could you provide me with the steps to create my .htaccess file. I don't have a clue how to do this?
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
philjones85Commented:
is this just for looks?  wouldn't it be easier to just put all your pages in a frame?  
0
 
carter_jlAuthor Commented:
This is just for looks, my site uses css.
0
 
philjones85Commented:
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
 
carter_jlAuthor Commented:
I used css to escape from frames. I just need the .htaccess file in order to rewrite the url.
0
 
philjones85Commented:
is your server a linux or windows server?
0
 
carter_jlAuthor Commented:
linux
0
 
philjones85Commented:
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
 
carter_jlAuthor Commented:
yes
0
 
philjones85Commented:
do you know how to use vi?
0
 
philjones85Commented:
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
 
carter_jlAuthor Commented:
I'll try this solution when I get home.

Thanks
0
 
carter_jlAuthor Commented:
This solution did not work, it only took me back to the www.oandcenterprises.com directory.
0
 
philjones85Commented:
try it with

RewriteRule ^(.*)$ http://www.oandcenterprises.com [R=301,L]
0
 
carter_jlAuthor Commented:
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
 
philjones85Commented:
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
 
carter_jlAuthor Commented:
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
 
carter_jlAuthor Commented:
Just for your efforts, ill award you the points.
0
 
philjones85Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.