Solved

Mod Rewrite

Posted on 2003-11-23
8
299 Views
Last Modified: 2010-03-04
I'm trying to shorten the urls below using .htaccess so that the category called "Web Development" and subcategory "HTML Tools" will appear as directories. Specifically, the category url:

http://www.mydomain.com/tools/software/showpads.php?cat=Web%20Development

needs to appear as:

http://www.mydomain.com/tools/software/web_development

and subcategory url:

http://www.mydomain.com/tools/software/showpads.php?cat=Web%20Development%3A%3AHTML%20Tools

should appear as

http://www.mydomain.com/tools/software/web_development/html_tools

Thanks in advance.

0
Comment
Question by:emory7
  • 3
  • 2
8 Comments
 
LVL 27

Accepted Solution

by:
BigRat earned 250 total points
ID: 9824986
RewriteEngine on
RewriteLog logs/rewrite
RewriteLogLevel 0
RewriteRule ^/tools/software/web_development/html_tools$  /tools/software/showpads.php?cat=Web%20Development%3A%3AHTML%20Tools [L]

RewriteRule
^/tools/software/web_development$ /tools/software/showpads.php?cat=Web%20Development

OK?

0
 

Author Comment

by:emory7
ID: 9855994
Hi,
I put the above code in .htaccess in the root and then tried it in the "software" directory (where the database script is installed). I got a server error both times. Wondering what I might be doing wrong?

Thanks much.
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 9922044
You need to provide exactly what the server error is to help us.

Possible problems:

Is mod_rewrite loaded
Is mod_alias loaded before mod_rewrite
Do you have the line 'RewriteEngin on' after the module is loaded

Try changing RewriteLogLevel to 3 instead of 0, and tell us what errors you get in the log file.

0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 22

Assisted Solution

by:pjedmond
pjedmond earned 250 total points
ID: 9922100
You don't want that [L] on the RewriteRules already given by BigRat - Should be:
-------------X8-----------------
RewriteEngine on
RewriteLog logs/rewrite
RewriteLogLevel 0
RewriteRule ^/tools/software/web_development/html_tools$  /tools/software/showpads.php?cat=Web20Development%3A%3AHTML%20Tools

RewriteRule ^/tools/software/web_development$ /tools/software/showpads.php?cat=Web%20Development
-------------X8-----------------

Try using the 'AllowOverride all' directive applied to the directory in which you have the .htaccess file

Other than the above ideas, we need feedback to locate the source of the problem

HTH:)
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 9922114
Oooops - should be:

'RewriteEngine on'

with an 'e' in my first posting!
0
 
LVL 27

Expert Comment

by:BigRat
ID: 9927444
One of the problems with putting this sort of thing into .htaccess, is that the web server has to find the .htaccess file from the URL, which involves resolving the URL in filestore.

I always put this sort of rewrite in the httpd.conf file, which requires access to the file, but allows me to rewrite almost anything ionto anything else.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

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…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

12 Experts available now in Live!

Get 1:1 Help Now