Go Premium for a chance to win a PS4. Enter to Win

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

Mod Rewrite

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
emory7
Asked:
emory7
  • 3
  • 2
2 Solutions
 
BigRatCommented:
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
 
emory7Author Commented:
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
 
pjedmondCommented:
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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
pjedmondCommented:
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
 
pjedmondCommented:
Oooops - should be:

'RewriteEngine on'

with an 'e' in my first posting!
0
 
BigRatCommented:
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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