admin管理员组

文章数量:1134232

hi i've created a staging site on subdomain / for testing purposes and put in on var/www/stagin, is on the same server as live site, staging and live site use different ports.

i created subdomain, pointed DNS, connected the database with Wordpress... changed URL to subdomain on database: define( 'WP_HOME', '' ); define( 'WP_SITEURL', '' );

staging site works. when i access a post, download or page from wordpress dashbord i can enter and see it without problem, but when i click view post, page or download i get: Not Found The requested URL was not found on this server.

it's the case for all my downloads, pages and posts. any help please.

my htaccess content:

I tried this:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^stagin\.mysite\$
RewriteRule ^(.*)$ /$1 [R=301,L]

<IfModule mod_headers.c>
Header set X-Robots-Tag "noindex, nofollow"
</IfModule>

and this:

<IfModule mod_rewrite.c>
#RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

but with same result

UPDATE:

now I've on my htaccess:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

<IfModule mod_headers.c>
Header set X-Robots-Tag "noindex, nofollow"
</IfModule>

I still have the same error.

this is what I verified:

  • permalinks structure is postname (the same as my live site)

  • in /etc/apache2/apache2.conf I have AllowOverride All:

    <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted

what I need

  • is there something to change in htaccess?

  • should I change all URLs in database from mysite to stagin.mysite with:

    UPDATE wp_posts SET post_content = replace(post_content, '', ''); & UPDATE wp_postmeta SET meta_value = replace(meta_value,'','');

-in htaccess when I have RewriteEngine On enabled and I go to stagin site homepage I get: Forbidden You don't have permission to access this resource. its not normal but the solution that I found is to disable #RewriteEngine On & change .htaccess permission to 0444 (if I keep it 0644 after some seconds RewriteEngine On is auto enabled.

That's the situation until now and just to remember, the main problem is: staging site works. when i access a post, download or page from wordpress dashbord i can enter and see it without problem, but when i click view post, page or download i get: Not Found The requested URL was not found on this server.

thanks

hi i've created a staging site on subdomain https://stagin.mysite.com/ for testing purposes and put in on var/www/stagin, is on the same server as live site, staging and live site use different ports.

i created subdomain, pointed DNS, connected the database with Wordpress... changed URL to subdomain on database: define( 'WP_HOME', 'https://stagin.mysite.com' ); define( 'WP_SITEURL', 'https://stagin.mysite.com' );

staging site works. when i access a post, download or page from wordpress dashbord i can enter and see it without problem, but when i click view post, page or download i get: Not Found The requested URL was not found on this server.

it's the case for all my downloads, pages and posts. any help please.

my htaccess content:

I tried this:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^stagin\.mysite\.com$
RewriteRule ^(.*)$ https://stagin.mysite.com/$1 [R=301,L]

<IfModule mod_headers.c>
Header set X-Robots-Tag "noindex, nofollow"
</IfModule>

and this:

<IfModule mod_rewrite.c>
#RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

but with same result

UPDATE:

now I've on my htaccess:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

<IfModule mod_headers.c>
Header set X-Robots-Tag "noindex, nofollow"
</IfModule>

I still have the same error.

this is what I verified:

  • permalinks structure is postname (the same as my live site)

  • in /etc/apache2/apache2.conf I have AllowOverride All:

    <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted

what I need

  • is there something to change in htaccess?

  • should I change all URLs in database from mysite.com to stagin.mysite.com with:

    UPDATE wp_posts SET post_content = replace(post_content, 'https://teesvg.com', 'https://stagin.teesvg.com'); & UPDATE wp_postmeta SET meta_value = replace(meta_value,'https://teesvg.com','https://stagin.teesvg.com');

-in htaccess when I have RewriteEngine On enabled and I go to stagin site homepage I get: Forbidden You don't have permission to access this resource. its not normal but the solution that I found is to disable #RewriteEngine On & change .htaccess permission to 0444 (if I keep it 0644 after some seconds RewriteEngine On is auto enabled.

That's the situation until now and just to remember, the main problem is: staging site works. when i access a post, download or page from wordpress dashbord i can enter and see it without problem, but when i click view post, page or download i get: Not Found The requested URL was not found on this server.

thanks

Share Improve this question edited Aug 6, 2023 at 12:24 PC Welcome asked Aug 5, 2023 at 19:06 PC WelcomePC Welcome 153 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I'd change the first part of your htaccess from

RewriteEngine On
RewriteCond %{HTTP_HOST} !^stagin\.mysite\.com$
RewriteRule ^(.*)$ https://stagin.mysite.com/$1 [R=301,L

to

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

This will take any request to any site and force it to SSL. Then the rest of the htaccess will take care of the WordPress stuff.

I think that your first rule is looking for 'anything not the staging url' and doing the SSL rewrite. Which means that any staging URL will not be processed (SSL'd), and the WP part will not work properly.

本文标签: multisiteStaging site on subdomainall links dont work except home page