Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

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.
0
carter_jl
Asked:
carter_jl
  • 10
  • 10
1 Solution
 
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
 
philjones85Commented:
is this just for looks?  wouldn't it be easier to just put all your pages in a frame?  
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
philjones85Commented:
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
 
carter_jlAuthor Commented:
Just for your efforts, ill award you the points.
0
 
philjones85Commented:
thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 10
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now