Solved

Mod Rewrite

Posted on 2003-11-23
8
304 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 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