programing

서버에서 mod_rewrite가 활성화 되어 있는지 확인하는 방법

firstcheck 2022. 11. 27. 17:38
반응형

서버에서 mod_rewrite가 활성화 되어 있는지 확인하는 방법

현재 광속 서버로 호스팅을 사용하고 있습니다.호스팅에 따르면mod_rewrite활성화 되어 있는데 스크립트가 동작하지 않습니다.URL에 접속하려고 하면 404 - not found 페이지가 반환됩니다.

Apache에서 실행되는 다른 서버에 동일한 코드를 넣었습니다.저기에서 작동한다..htaccess ★★★★★★★★★★★★★★★★★」mod_rewritedisclossible을 클릭합니다.

그러나 호스트 지원에서는 mod_rewrite가 켜져 있다고 주장하고 있기 때문에 실제로 활성화 되어 있는지 여부를 어떻게 확인할 수 있는지 알고 싶습니다.

phpinfo()이 없다.는 찾을 수 , 찾을 수 없다.mod_rewrite이 '아, 아, 아, 아, 아, 아'를 사용하고 있기 때문에?lightspeed

확인할 수 있는 방법이 있나요?제발 도와주세요.감사해요.

참고: 나의.htaccess는 「」입니다.

Options -Indexes

<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>

저도 이렇게 해봤어요.

DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

하지만 결과는 똑같다.

명령줄에 다음과 같이 입력합니다.

sudo a2enmod 개서

개서 모드가 이미 유효하게 되어 있는 경우는, 그렇게 통지됩니다.

  1. mod_rewrite 모듈이 활성화 되어 있는지 확인하려면 WAMP 서버의 루트 폴더에 새로운 php 파일을 만듭니다.다음을 입력합니다.

    phpinfo();

  2. 브라우저에서 작성한 파일에 액세스합니다.

  3. CtrlF 검색을 엽니다.'mod_rewrite'를 검색합니다.활성화되어 있으면 '로드된 모듈'로 표시됩니다.

  4. 그렇지 않으면 httpd.conf(Apache Config 파일)를 열고 다음 행을 찾습니다.

    #LoadModule rewrite_module modules/mod_rewrite.so

  5. 선두에 있는 파운드 기호('#')를 삭제하고 이 파일을 저장합니다.

  6. Apache 서버를 재시작합니다.

  7. 브라우저에서 동일한 php 파일에 액세스합니다.

  8. 'mod_rewrite'를 다시 검색하십시오.이제 찾을 수 있을 거예요.

하고 있는 는, 에, 「」의 디렉티브가 있는 것을 .AllowOverride All다음과 같이 합니다.

<VirtualHost *:80>
        ...
    <Directory "directory/of/your/.htaccess">
        AllowOverride All
    </Directory>
</VirtualHost>

기본적으로 이 상태는 모든 .htaccess 디렉티브를 처리할 수 있도록 합니다.

이것은 Cent에서 동작합니다.OS:

$ sudo httpd -M |grep rewrite_module

해야 합니다.rewrite_module (shared)

콘솔:

<VirtualHost *:80>
        ...
    <Directory ...>
        AllowOverride All
    </Directory>
</VirtualHost>

sudo a2enmod rewrite
sudo service apache2 restart

apache_get_modules()가 인식되지 않거나 phpinfo()에 이 모듈에 대한 정보가 없는 경우 .htaccess 파일에 이러한 행을 추가하여 mod rewrite를 테스트해 보십시오.

RewriteEngine On
RewriteRule ^.*$ mod_rewrite.php

그리고 mod_rewrite.php:

<?php echo "Mod_rewrite is activated!"; ?>

PHP의 정의된 함수는 활성화된 모듈 목록을 반환합니다.확인하다mod_rewrite할 수 .서버에서 다음 스크립트를 실행할 수 있습니다.

<?php
print_r(apache_get_modules());
?>

실패했을 하려면 mod-rewrite를 합니다..htaccess파일.

작성하다htaccess다음 rewriteRule을 추가합니다.

RewriteEngine on

RewriteRule ^helloWorld/?$ /index.php [NC,L]

이제 http://example.com/HelloWorld에 접속하여 사이트의 /index.http://index.http://http://example.com/HelloWorld 페이지로 내부 전송 됩니다.그렇지 않으면 mod-rewrite가 비활성화되면 500 Internel 서버 오류가 발생합니다.

이게 도움이 됐으면 좋겠다.

한다면

in_array('mod_rewrite', apache_get_modules())

돌아온다truemod-internal 이 네이블이 됩니다.

단말기에서 다음 중 하나를 수행할 수 있습니다.

apachectl -M
apache2ctl -M

2daygeek에서 가져온

이 코드가 .htaccess 파일에 있는 경우(mod_rewrite.c 체크 없음)

DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

500 서버 에러가 발생하고 있는 사이트상의 어느 페이지에도 액세스 할 수 있습니다.mod rewrite가 켜져 있다고 해도 무방합니다.

php 함수를 사용할 수 있습니다.

      apache_get_modules

mod_model을 확인합니다.

<pre>
<?php
print_r(apache_get_modules());
?>
</pre>

http://in2.php.net/apache_get_modules

Linux 시스템에 있는 경우 /etc/apache2/mods-available 폴더에서 모든 enable 모듈에서 apache2(내 경우)를 확인할 수 있습니다.

cd /etc/apache2/mods-available

입력 방법:ll -a
php (이 경우는 php 7 )폴더 /etc/sys/7.0/mods-available 을 체크하는 경우

cd /etc/php/7.0/mods-available

입력 방법:ll -a

오래된 질문이지만 Apache 구성 파일을 편집하여AllowOverride All부터AllowOverride None

<Directory "${SRVROOT}/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

새 페이지를 만들고 이 코드를 추가하세요.

 <?php
 if(!function_exists('apache_get_modules') ){ phpinfo(); exit; }
 $res = 'Module Unavailable';
 if(in_array('mod_rewrite',apache_get_modules())) 
 $res = 'Module Available';
?>
<html>
<head>
<title>A mod_rewrite availability check !</title></head>
<body>
<p><?php echo apache_get_version(),"</p><p>mod_rewrite $res"; ?></p>
</body>
</html>

이 페이지를 실행하면 모듈을 찾을 수 없거나, 이 페이지를 찾을 수 없거나 로컬 시스템에 Apache > Apache > 사이트 > Apache https://youtu.be/xIspOX9FuVU?t=1m43s을 사용하도록 설정할 수 있습니다. 거기.쓰기 모듈 옵션

이 코드는 나에게 유효했다.

if (strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false) echo "mod_rewrite enabled";
else echo "mod_rewrite disabled";

먼저 모듈이 장착되어 있는지 확인합니다.

apachectl -M

목록에 표시되지 않을 경우 활성화해야 합니다.

a2enmod rewrite

이제 서버를 재시작하고 테스트합니다.

systemctl restart apache2

파일이 있는지 확인만 하면 됩니다.

cat /etc/apache2/mods-available/rewrite.load

결과 행에 코멘트를 붙일 수 없습니다.#

정확히 문제가 있어서 커스텀 구조를 클릭한 후 추가함으로써 해결했습니다./index.php/%postname%/그리고 그것은 동작한다.

이게 내가 겪은 스트레스를 누군가 덜어주길 바라. 그게 대체 뭐가 문제인지 말야.

언급URL : https://stackoverflow.com/questions/7337724/how-to-check-whether-mod-rewrite-is-enable-on-server

반응형