www.webdeveloper.com
Results 1 to 2 of 2

Thread: Trouble creating .htaccess re-write rules

  1. #1
    Join Date
    Jul 2012
    Posts
    4

    Trouble creating .htaccess re-write rules

    I want to change example.com/xxx/* to example.com/yyy/* . I have spent a lot of time on this but can't seem to figure it out. Here is what I started with:

    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    And here is what I've tried added:

    Code:
    Options +FollowSymLinks  
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
     
    RewriteRule example.com/xxx/ ./yyy/$1  
    RewriteRule example.com/aaa/ ./bbb/$1  
    
    </IfModule>
    
    # END WordPress
    The code doesn't seem to do anything. What am I doing wrong?

    Thank you.

  2. #2
    Join Date
    Nov 2011
    Posts
    9
    @guinnee, I think you need a 301 redirect for what you're trying to accomplish, not mod_rewrite.

    ...though, I could be wrong, I have an .htaccess issue myself.

    Also, sorry if you feel I'm hijacking your thread, but since mine is a similar issue, it's probably best I post here rather than start another.

    My problem is that I want to ignore anything longer than what I'm rewriting,rather than throwing a 404 error.

    So: example.com/topic/correct-value/but-this-throws-an-error/

    Should strip: but-this-throws-an-error/

    This is what I have:
    Code:
    RewriteEngine on
    RewriteBase /
    RewriteRule ^tema/$ topics.php [L]
    RewriteRule ^topic/$ topics.php [L]
    RewriteRule ^topic/(.*)/$ topic.php?tag=$1 [L]
    RewriteRule ^tema/(.*)/$ topic.php?tag=$1&language=es [L]
    I should also mention I plan to add a third param to the query string, "page="

    so ultimately: example.com/topic/correct-value/1/ <--(last param numeric only) will be allowed, anything else striped and redirected to /correct-value/
    Last edited by ohnos; 03-04-2013 at 02:54 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles