source

.htaccess / Apache2를 사용하여 간단한 php 애플리케이션으로 하위 디렉토리에서 워드프레스 애플리케이션을 구성하는 방법은 무엇입니까?

nicesource 2023. 7. 18. 21:47
반응형

.htaccess / Apache2를 사용하여 간단한 php 애플리케이션으로 하위 디렉토리에서 워드프레스 애플리케이션을 구성하는 방법은 무엇입니까?

간단한 php 어플리케이션으로 워드프레스 어플리케이션을 구성하고 싶습니다.응용프로그램의 디렉토리 구조는 다음과 같습니다.

루트 디렉토리: /var/www/demoApp/

워드프레스 디렉토리 : /var/www/demoApp/wordpress/

여기서 저는 route http://BASE_URL/wordpress를 사용하여 워드프레스 애플리케이션에 액세스하고 싶습니다.하지만 저는 htaccess 파일을 구성할 수 없습니다./var/www/demoApp/ 디렉토리의 모든 php 페이지는 url http://BASE_URL/을 사용하여 정상적으로 작동합니다.워드프레스 파일이 올바르게 로드되지 않는 동안.

다음은 Apache 구성 블록입니다.

<VirtualHost *:80>
    ServerName localhost

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/demoApp

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/demoApp>
            Options FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>


    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

.htaccess 파일은 무엇이어야 합니까?

내 구성:

도메인: test.localhost

wordpress url: test.localhost/wordpress

wordpress 폴더의 .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress

하위 도메인에 대한 Apache 설정(윈도우즈 아래 Wamp 서버)

<VirtualHost *:80>
    DocumentRoot "e:\Sync\www\test"
    ServerName localhost
    ServerAlias test.localhost

    <Directory "e:\Sync\www\test">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
    Allow from ::1
    </Directory>

</VirtualHost>

몇 가지 절대 경로를 상대 경로로 수정하는 동안 이 문제가 발생했습니다.문제는 제가 여분을 남겼다는 것입니다./상대 경로의 시작 부분에서.

올바른 코드:

<a href="about">About</a>   
<!--The link goes to to http://BASE_URL/wordpress_subdirectory/about-->

잘못된 코드:

<a href="about">/About</a>
<!--This href is relative to the 'Root'. It goes to http://BASE_URL/about-->

언급URL : https://stackoverflow.com/questions/44565032/how-to-configure-wordpress-application-in-subdirectory-with-simple-php-applicati

반응형