0

I just did a huge makeover to a site and changed the framework. Because of that, the structure of urls changed. This is not a huge problem except for one url which is used a lot. I need to redirect user from the old address to the new one, and I just cannot figure out how to do that.

  • Old url: domain/?page/subpage/subsubpage.html?param=[parameter]/
  • New url: domain/controller/function/[parameter]/

My rewrite rules currently are this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [L]
RewriteRule ^/\?page/subpage/subsubpage.html\?param=(.*)$ /controller/function/$1 [L]

but it does not work, no redirect is happening.

Edit: Added the whole htaccess file! This currently gives me error 500 ( "Request exceeded the limit of 10 internal redirects due to probable configuration error.")

Options +FollowSymLinks

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    <Files .*>
        Order Deny,Allow
        Deny From All
    </Files>

    # Allow asset folders through
    RewriteRule ^(fuel/modules/(.+)?/assets/(.+)) - [L]
    RewriteRule ^(fuel/modules/(.+)?/tuki/(.+)) - [L]
    RewriteRule ^(fuel/modules/(.+)?/wiki/(.+)) - [L]
    
    

    # Protect application and system files from being viewed
    RewriteRule ^(fuel/install/.+|fuel/crons/.+|fuel/data_backup/.+|fuel/codeigniter/.+|fuel/modules/.+|fuel/application/.+) - [F,L]


    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    

    RewriteRule ^/\?page/subpage/subsubpage.html\?param=(.*)$ /controller/function/$1 [L]



    RewriteRule .* index.php/$0 [L]

    
    # Prevents access to dot files (.git, .htaccess) - security.
    RewriteCond %{SCRIPT_FILENAME} -d
    RewriteCond %{SCRIPT_FILENAME} -f
    RewriteRule "(^|/)\." - [F]
    
    
</IfModule>
Options -Indexes
1
  • Old url: domain/?page/subpage/subsubpage.html?param=[parameter]/: Do you have ? twice in old URL? Commented Mar 5, 2021 at 14:36

1 Answer 1

1

With your shown samples/attempts could you please try following. Please make sure you clear your browser cache before testing your URLs.

Options +FollowSymLinks
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine ON
RewriteBase /

<Files .*>
Order Deny,Allow
Deny From All
</Files>

# Prevents access to dot files (.git, .htaccess) - security.
RewriteRule \.(git|htaccess) - [F]

# Allow asset folders through
RewriteRule ^fuel/modules/(assets|tuki|wiki) - [L]

# Protect application and system files from being viewed
RewriteRule ^fuel/(install|crons|data_backup|codeigniter|modules|application)/.+ - [F,L]

##Any non existing directory OR files whose URI srarts from page rule.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/\?page/subpage/subsubpage.html\?param=(.*)$ /controller/function/$1 [L]

####If any non existing directory OR file is requested then come here:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php/$0 [L]
    
###New rule added by me here.....
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
ReWriteCond %{QUERY_STRING} .*=([^/[]*)/?$
RewriteRule ^ controller/function/%1 [L]  
</IfModule>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.