2017-11-17 3 views
0

は、私はこのような私のURLのルールを書き換えたい表示されます。のRewriteRuleが動作し、エラー500が

https://mywebsite.com/dev/index.php?controller=pages&action=inscription

https://mywebsite.com/dev/inscription

に瞬間私のhtaccessファイルについてこの手順が含まれています:

RewriteEngine On 
RewriteRule ^([^/]*)/([^/]*)$ /dev/index.php?controller=$1&action=$2 [L] 
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /dev/index.php?controller=$1&action=$2&id=$3 [L] 

これはURLの2 RewritRules作品:

/dev/index.php?controller=sport&action=accueil --->/dev/sport/accueil /dev/index.php?controller=sport&action=produit&id=1 --->ここ/dev/sport/produit/1

特異値、 "ページ" に持っているすべてのコントローラ、1 RewriteUrlに割り当てることですこのようにしますが、エラーにします500:

RewriteRule ^([^/]*)$ /dev/index.php?controller=pages&action=$1 [L] 

ご協力いただきありがとうございます。詳細が必要な場合は、コメントを残してください。

答えて

0

このルールは、問題であると思われる:

RewriteRule ^([^/]*)$ /dev/index.php?controller=pages&action=$1 [L] 

パターン[^/]*が同様URI /index.php書き換え照合されるので、それは無限ループを引き起こしています。

すべてのファイルに&ディレクトリをスキップするだけでRewriteEngine On線の下にこのルールを挿入します。

RewriteEngine On 

# skip all files and directories from rewrite rules below 
RewriteCond %{REQUEST_FILENAME} -d [OR] 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule^- [L] 

# all your rewrite rules go below this 

はまた、あなたの.htaccessが/dev/ディレクトリ内にある場合、あなたはターゲットなどにindex.php代わりの/dev/index.phpを使用できることに注意してください。

RewriteRule ^([^/]*)$ index.php?controller=pages&action=$1 [L,QSA] 
+0

これは機能しましたか? – anubhava

関連する問題