Solved

Mod Rewrite

Posted on 2003-11-23
8
303 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
[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
  • 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

710 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