Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help me get a really simple mod_rewrite to work?

Posted on 2013-11-04
5
Medium Priority
?
345 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
[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
5 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month12 days, 6 hours left to enroll

636 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