Solved

Help me get a really simple mod_rewrite to work?

Posted on 2013-11-04
5
326 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 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem with .htaccess file 4 73
how to use external config file with Spring MVC 4 157
Apache / XAMPP  authorisation 10 70
Certificate Request CentOS/Apache 1 23
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 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