Eliminar / Redirigir public / index.php de la URL para evitar URL duplicadas

kunal

Hola, tengo un problema para eliminar public / index.php de la URL. Eliminar / Redirigir index.php de la URL para evitar URL duplicadas Este enlace realmente me ayuda a eliminar la URL del formulario index.php, pero no puedo eliminar public / index.php de la URL. Aquí está mi siguiente código htacces

 RewriteEngine On
 #REmove index.php from url starts
    RewriteCond %{THE_REQUEST} /index\.php [NC]
    RewriteRule ^(.*?)index\.php[^/] /$1? [L,R=302,NC,NE]

    RewriteCond %{THE_REQUEST} /index\.php [NC]
    RewriteRule ^(.*?)index\.php(?:/(.*))?$ /$1$2? [L,R=302,NC,NE]
 #Remove index.php from url ends

   RewriteCond %{HTTPS} off
   RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

   RewriteCond %{HTTP_HOST} !^www\. [NC]
   RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

 <IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$    public/    [L]
   RewriteRule    (.*) public/$1    [L]
</IfModule>

Pero cuando agrego este código a continuación para eliminar public / index.php en htaccess, no funciona: -

RewriteCond %{THE_REQUEST} /public/index\.php [NC]
RewriteRule ^(.*?)public/index\.php[^/] /$1? [L,R=302,NC,NE]

RewriteCond %{THE_REQUEST} /public/index\.php [NC]
RewriteRule ^(.*?)public/index\.php(?:/(.*))?$ /$1$2? [L,R=302,NC,NE]

Ejemplos de URL que deben redirigirse:

  1. mydomain.com/public/index.php/somethingdebe ser redirigido a mydomain.com/something(algo podría ser cualquier cosa, puede contener cualquier carácter)
  2. mydomain.com/public/index.php debe ser redirigido a mydomain.com
  3. mydomain.com/index.php?anythingdebe ser redirigido a mydomain.com?anything(cualquier cosa puede contener cualquier carácter)

Ayúdame a resolver este problema.

anubhava

Puede usar esta regla en el interior public/.htaccess:

RewriteEngine On

RewriteCond %{THE_REQUEST} /public/index\.php(?:[/?](\S+))?\sHTTP [NC]
RewriteRule ^ /%1 [L,R=301,NE]

RewriteCond %{THE_REQUEST} /public/(\S*)\sHTTP [NC]
RewriteRule ^ /%1 [L,R=301,NE]

# other rules below this line

Además, use este código en la raíz del sitio .htaccess:

RewriteEngine On

# remove /index.php
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]

RewriteRule ^ public%{REQUEST_URI} [L]

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Removing index.php from url in codeigniter

分類Dev

CodeIgniter removing index.php from URL not working

分類Dev

htaccess - rewrite url from /test to index.php?page=test

分類Dev

rewrite URL from /index.php?page=about to /page/

分類Dev

url.Actionlink to another website to index.php

分類Dev

how to remove url (/web/index.php) yii 2 and set route with parameter with clean url?

分類Dev

Laravel-PHP職人サーブURL(127.0.0.1:8000)vs localhost / laravelproject / public

分類Dev

URLで生成されたLaravelから「public / index.php」を削除するにはどうすればよいですか?

分類Dev

google storage signed url public read

分類Dev

Remove public from URL Laravel 5.3

分類Dev

Changing public url in knative service definition

分類Dev

url /index.phpをurl / homeにリダイレクトする方法

分類Dev

Converting a string into URL PHP

分類Dev

PHP/Apache Nice URL

分類Dev

Issue in Passing Url in PHP

分類Dev

PHP url array search and return closest url

分類Dev

php url rewrite remove?= from url

分類Dev

Yii2URLからindex.phpを削除します

分類Dev

URL Laravel5からindex.phpを削除します

分類Dev

CodeIgniterがURLからindex.phpを削除しています

分類Dev

codeigniterはindex.phpフォームのURLを削除します

分類Dev

Codeigniter3.1.6-URLからindex.phpを削除する方法

分類Dev

Laravel 5.8URLからindex.phpを削除します

分類Dev

Htaccess index.phpを削除しますか?URLから

分類Dev

codeigniterは、URLのindex.phpでのみ機能します

分類Dev

codeigniterがwampのURLからindex.phpを削除する

分類Dev

NginxCodeIgniterはURLのindex.phpを削除します

分類Dev

URLのindex.phpを削除する正しい方法

分類Dev

Codeigniter 3.0URLからindex.phpを削除できません

Related 関連記事

  1. 1

    Removing index.php from url in codeigniter

  2. 2

    CodeIgniter removing index.php from URL not working

  3. 3

    htaccess - rewrite url from /test to index.php?page=test

  4. 4

    rewrite URL from /index.php?page=about to /page/

  5. 5

    url.Actionlink to another website to index.php

  6. 6

    how to remove url (/web/index.php) yii 2 and set route with parameter with clean url?

  7. 7

    Laravel-PHP職人サーブURL(127.0.0.1:8000)vs localhost / laravelproject / public

  8. 8

    URLで生成されたLaravelから「public / index.php」を削除するにはどうすればよいですか?

  9. 9

    google storage signed url public read

  10. 10

    Remove public from URL Laravel 5.3

  11. 11

    Changing public url in knative service definition

  12. 12

    url /index.phpをurl / homeにリダイレクトする方法

  13. 13

    Converting a string into URL PHP

  14. 14

    PHP/Apache Nice URL

  15. 15

    Issue in Passing Url in PHP

  16. 16

    PHP url array search and return closest url

  17. 17

    php url rewrite remove?= from url

  18. 18

    Yii2URLからindex.phpを削除します

  19. 19

    URL Laravel5からindex.phpを削除します

  20. 20

    CodeIgniterがURLからindex.phpを削除しています

  21. 21

    codeigniterはindex.phpフォームのURLを削除します

  22. 22

    Codeigniter3.1.6-URLからindex.phpを削除する方法

  23. 23

    Laravel 5.8URLからindex.phpを削除します

  24. 24

    Htaccess index.phpを削除しますか?URLから

  25. 25

    codeigniterは、URLのindex.phpでのみ機能します

  26. 26

    codeigniterがwampのURLからindex.phpを削除する

  27. 27

    NginxCodeIgniterはURLのindex.phpを削除します

  28. 28

    URLのindex.phpを削除する正しい方法

  29. 29

    Codeigniter 3.0URLからindex.phpを削除できません

ホットタグ

アーカイブ