Forum Moderators: phranque
-what I ve been asked to do right now is replace & and? of query string with /(slashes).
does .htaccess file places in the directory where script present? can we have more than one .htaccess on a single machine?
any idea?
-adnan
Start with the mod_rewrite documentation [httpd.apache.org] and try this short regex tutorial [etext.lib.virginia.edu].
You can have one .htaccess file in each directory/subdirectory, although it is best to minimize them because all .htaccess files in a path will have to be processed to serve a file in that path, and .htaccess processing is somewhat inefficient compared to httpd.conf.
HTH,
Jim
[xyz.com...]
show_accessories.jsp?prod_id=460&brand_name=Nokia
to
[xyz.com...]
prod_id/460/id=jsp/show_accessories.jsp/prod_id/460/
brand_name/Nokia
any help?is it possible?
-adnan
[edited by: Marcia at 8:00 am (utc) on Dec. 22, 2002]
[edit reason] side scroll [/edit]
The second sample you showed is still way too long. Take some time and give more thought before you change your file structure. You'd be better off with URLs right around 35 characters. It can make a difference in a number of different ways. For one thing, on pages linking to those, long URLs will bloat the file size, and you should keep page text and html small in size. Secondly, who would link to URLs that long? It wuuld be very difficult to do.
There's more to think about than just the technical aspects, so take your time and dig in reading a bit more. There's a search available - top of the page - so you can look up different things as you go along.
this simple example is also not workin for me on my linux box how do i test it? though i know that mod rewrite is installed,whenever i go to [localhost...] then it doesnt go to page2.html,any idea?
thanx
/var/www/html/myphp/
so local host is
[localhost...]
and i put files in /var/www/html/myphp/,htmls and .htacess files
Assuming your local server is configured similarly to a typical hosted account...
There are hundreds of options in the httpd.conf file that control how Apache behaves. I'm thinking your problem is in this area. If you have a hosted account somewhere, you could use it to confirm that the redirect works, then attempt to configure your local server.
<added>
I set up Apache on my Red Hat 7.1 distro, been meaning to do it and finally have a reason. :) I can't surf to [localhost...] either but I can surf to [machinename...] and, after massaging my httpd.conf file, my .htaccess file works as advertised.
By machinename, I'm referring to the computer's name for networking purposes. I'm not sure how to describe it. When logged into the root directory as root, the prompt in a terminal window displays "root@machinename /root" Another way to say it is, it's the name this machine is known by on my local network.
<added>
-another thing is RewriteLog "mylog.log" wasnt working too and i was gettin 505 Internal server error,i checked error_log then i found there that .htacess,RewriteLog isn`t allowed,i dont know why
-Now i wll come back soon with orignal problems
Thanx a lot,this forum is great
-adnan
things are going pretty fine yet, belated Xmas greetings to all of you
-well 2 questions first one is
-when i add RewriteLog then apache error_log says something like
[Fri Dec 27 16:05:27 2002] [alert] [client 127.0.0.1] /var/www/html/shopcart/_admin/.htaccess: RewriteLog not allowed here
-how do i do that?
Second question is that is there anyway to write a single rule for all files
i mean i want whenever someone hits *.html files it goes to *.php files
e:g file1.html->file1.php
file5.html->file5.php
or do i need to write rules/files?
thanx
Something like this should perform the redirect you need:
Options +FollowSymLinks
RewriteRule ^(.*)\.html $1.php [L]
The "$1" in the URL on the right adds the pattern matched on the left into the URL on the right.
another question, asked by my friend
he wants the url
[domainname.com...]
to
[domainname.com...] jsp/prod_id/460/id/jsp/show_accessories.jsp/
prod_id/460/brand_name=Nokia
i:e replacing? and & with "/"
- i told em that i ve been workin on rewrite so he asked em to do so, it this url sane? can it be parsed by rewrite url?
thanx
[edited by: DaveAtIFG at 6:30 am (utc) on Dec. 28, 2002]
Frankly, I don't understand why you would want to do this rewrite and I agree with Marcia's comments in message #5.
I bet you mod_rewrite is being used for WebmasterWorld threads making them look like static HTML files when in fact they are dynamic pages.
I didn't understand your question... but after reviewing some of your other posts, I think this Intro to Redirecting URLs [webmasterworld.com] probably will be useful to you.