Solved

Help me get a really simple mod_rewrite to work?

Posted on 2013-11-04
5
301 Views
Last Modified: 2013-11-04
I am trying to create a Rewrite Rule in htaccess that will take a url such as
http://www.myplace.com/vwxyz

and rewrite it to

http://www.myplace.com/index.php/?cx=vwxyz

My server has recently been upgraded from Apache to LiteSpeed but according to the documentation it uses standard htaccess files (but without a performance hit)

The entire contents of the .htaccess file is as follows:

RewriteEngine on
RewriteRule ^c/([^/\.]+)/?$ index.php?cx=$1 [L]

and I've tried it both in the root and in the public_html directory.

What I get is

 404 Not Found
The resource requested could not be found on this server! Powered By LiteSpeed Web Server
LiteSpeed Technologies is not responsible for administration and contents of this web site!

Maybe I need a rewritecond but I don't know what that should be.  

For someone who knows this may be a laughably simple question - but I've spent way to much time trying to figure it out on my own.  A good answer is well worth the 500 points!
0
Comment
Question by:DMTrump
  • 3
  • 2
5 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39622957
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?cx=$1 [L]
0
 

Author Comment

by:DMTrump
ID: 39623065
Bravo!  Works like a charm...

Now please explain what the two RewriteCond statements do so I'm a little smarter next time

I found that the trouble with most online documentation is it frequently shows stubs rather than complete examples!  Aaargh!
0
 

Author Closing Comment

by:DMTrump
ID: 39623069
Thanks a lot!  It's been years since I last messed with htaccess and I seemed to have forgotten everything I knew - which wasn't much!
0
 
LVL 58

Expert Comment

by:Gary
ID: 39623078
The two rewrites check the file or directory don't exist so the rewrite rule only fires if they don't
0
 

Author Comment

by:DMTrump
ID: 39623406
thanks!  I really appreciate your willingness to help an oldie having a newbee moment!

I'll study more of the htaccess documentation when I'm not in such a blinking hurry!
500 points well spent - okay, I have an unlimited account, so it didn't cost me anything extra - but still - thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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). #…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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