简体   繁体   English

如何使用 .htaccess 将 URL 重定向到新的 URL?

[英]How to redirect URL into a new URL using .htaccess?

I want to redirect pages using .htaccess.我想使用 .htaccess 重定向页面。 I am using code igntiter When user type this URL in addresss bar:我正在使用代码 igntiter 当用户在地址栏中键入此 URL 时:

form.bixy.com/salesapp

and they hit enter button, the URL should changed into:然后他们按下回车键,URL 应该变成:

form.bixy.com/salesapp/administrator/addusr

I have this .htaccess inside the salesapp folder我在salesapp文件夹中有这个 .htaccess

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond $1 !^(index\.php|images|stylesheets|system/application/sources/) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/  

</IfModule>

If the line RewriteRule ^(.*)$ index.php?/ is removed, I got The requested URL was not found on this server.如果RewriteRule ^(.*)$ index.php?/行被删除,我得到了The requested URL was not found on this server.

I have little knowledge about .htaccess.我对 .htaccess 知之甚少。 Any help is greatly appreciated, thanks in advance.非常感谢任何帮助,在此先感谢。

Edit:编辑:

This is my current .htaccess that I put inside salesapp folder:这是我放在salesapp 文件夹中的当前 .htaccess :

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond $1 !^(index\.php|images|stylesheets|system/application/sources/)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)/?$ index.php  [L]

RewriteRule ^/? /salesapp/administrator/addusr[NC,R=301,L]

</IfModule>

It still give me error, but the URL should've worked它仍然给我错误,但 URL 应该可以工作

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Inside salesapp you can try this .htaccess:salesapp里面你可以试试这个 .htaccess:

RewriteEngine on
RewriteBase /salesapp/

RewriteRule ^(?:administrator)?/?$ administrator/addusr [R=301,L,NC]

RewriteCond $1 !^(index\.php|images|stylesheets|system/application/sources/) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php  [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM