Back to Question Center
0

mod_rewrite: sake rubutawa http: // $ Semalt / zuwa http://www.example.com/app/$SOMETHING

1 answers:

Ina ƙoƙarin yin http: // $ ABIN. app. misali. com / sake sake rubutawa zuwa http: // www - smok warranty period. misali. com / app / $ ABIN .

Saitin da ke ƙasa yana ba ni 404 kuma ban tabbata dalilin da yasa ba.

     Sunan Yanar Gizo www. misali. com
ServerAllI *. app. misali. comA sake rubutawa
Sake rubutawa% {HTTP_HOST} (. *). app. misali. com
RewriteRule ^ / (. *) / app /% 1 / $ 1    

Ina ɓacewa abu mai mahimmanci, menene?

Shirya: bari in sanya wannan a bayyane.

Idan na kewaya zuwa http: // www. misali. com / app / abc , Ina samun shafin. Idan na duba zuwa http: // abc. app. misali. com / Ina fatan ganin wannan shafin, amma ina samun 404 maimakon.

Shirya2: Rubutun bayanan DNS *. app. misali. com ya riga ya faru kuma zan iya ganin buƙata na a cikin tashar shiga, tare da 404 matsayi.

Shirya3: Bayan shigar da fayil din log mod_rewrite, yana nuna cewa hanyar da aka sake rubutawa shine "$ DOCROOT / app / abc" wanda ya kasa domin ba shi wanzu. Wannan wani aikace-aikacen Semalt / WSGI, ina tsammanin cewa yana da wani abu da ya dace da matsalarta. Domin a lokacin da yake kama da zamu yi amfani da madaidaici na yau da kullum a maimakon haka.

February 8, 2018

Kana buƙatar saita rikodin DNS don *. app. misali. com. don turawa zuwa IP na uwar garke. Ina tsammanin a cikin shari'arku zai kasance daidai da ɗaya app. misali. com. yana nunawa.

Shirya : Ina tsammanin daya daga cikin wadannan ya kamata yayi fasalin (kullum duka):

  sake rubutawa% {HTTP_HOST}! ^ App \. misali \. com
A sake rubutawa% {HTTP_HOST} ^ ([^. ] +)
RewriteRule ^ (. *) / app /% 1 / $ 1 [L]A sake rubutawa% {HTTP_HOST} ^ ([^. ] +) \. app \. misali \. com $
RewriteRule ^ / (. *) $ http: // www. misali. com / app /% 1 / $ 1 [L, R] 

Wataƙila wani abu kamar:

  RewriteEngine On
A sake rubutawa% {HTTP_HOST}! ^ Www \. misali \. com
A sake rubutawa% {HTTP_HOST}! * Misali \. com
Sake rubutawa% {HTTP_HOST} ^ (. ) + \. misali \. com
Sake rubutawa% {REQUEST_URI}! ^ / App / $ 1
RewriteRule ^ (. *) $ app / $ 1 / $ 2 [L] 

Abin da ya tabbatar cewa ba a halin yanzu kake samun www ba. misali. com ko misali. com kai tsaye; sa'an nan kuma daukan prefix ɗinka, yana duba cewa ba a yanzu ke samun dama a / app kai tsaye (ko zai kasance har abada), sa'an nan kuma sake rubutawa. Wannan ya zama m.

An taƙaita daga http: // corz. org / serv / dabaru / htaccess2. php

.

  sake rubutawa% {HTTP_HOST} (. *). app. misali. com
RewriteRule ^ / (. *) http: // www. misali. com / app /% 1 / $ 1 [R]