0

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

1 Answer 1

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.

3
  • i edited the post with an update please see it thanks so much
    – PC Welcome
    Aug 6 at 12:25
  • Are you trying to get to the home page with a menu item, or just typing in the URL? If a menu item, you may need to edit that menu item to have the proper URL. Is this a new install? Does the wp-settings.php point to the test/staging database (not the live one)? The test/staging should be a clone of the live, not the live database. Do the other staging links go to staging data, not live data? Aug 6 at 20:59
  • its not a menu but just typing in the URL. except for the homepage when i try to enter any URL, like stagin.mysite.com/downloads/howtocreatesomething i get: Not Found The requested URL was not found on this server. i copied all Wordpress live site files to staging site and also the database. wp-config.php point to staging database. other staging links go to staging data, not live data but I get: Not Found The requested URL was not found on this server.
    – PC Welcome
    Aug 7 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.