Seo Urls

Hi,

I am new with Yii2 framework. I am working on web which needs SEO URl, it means that one URL should have one content. If I use standard route




'urlManager' => [

			'enablePrettyUrl' => true,

			'showScriptName'  => false,

			'enableStrictParsing' => true,

			'matchValue' => true,

			'class'           => 'codemix\localeurls\UrlManager',


			// List all supported languages here

			// Make sure, you include your app's default language.

			'languages'       => [ 'cs', 'en', ],

			'rules'           => array(

				'<action:\+w>' => 'site/<action>'

			),

		],



I have same content on




/

and

/index

and

/index.php/



Is there a solution for redirecting duplicate urls to only one.




/ -> no redirect

/index -> redirect to /

/index.php -> redirect to /


/about -> no redirect

/site/about -> redirect to /about

/index.php/site/about -> redirect to /about



You can try this

demo.easyiicms.com/

demo.easyiicms.com/index.php

demo.easyiicms.com/site/index

same content on three URLs, this is seo killer

Add some rules, dude :)


            	

	'/' => 'site/index',

	'/about' => 'site/about',

	...



Also, you have ‘showScriptName’ set to ‘false’ so ‘index.php’ will never show.

It is not the problem, I have a problem that pages are accessible on two URLs. Url builder builds right links without "index.php", but if I write manually "index.php" to URL, it works without redirecting to "/"

Did you try link on my prev post. One content is accessible on two URLs




demo.easyiicms.com/index.php // I want to redirect this to demo.easyiicms.com/

demo.easyiicms.com/



Hi,

I solved my problem, a added to .htaccess




RewriteBase /


	#remove last / from URL

	RewriteCond %{REQUEST_FILENAME} !-d

	RewriteRule ^(.*)/$ /$1 [L,R=301]


	#redirect /index.php/*/*/....... to version without index.php

	RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]

	RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]




All my .htaccess




# Apache configuration file (see httpd.apache.org/docs/current/mod/quickreference.html)


# disable directory listing

<IfModule mod_autoindex.c>

	Options -Indexes

</IfModule>


# enable cool URL

<IfModule mod_rewrite.c>

	RewriteEngine On

	RewriteBase /


	#remove last / from URL

	RewriteCond %{REQUEST_FILENAME} !-d

	RewriteRule ^(.*)/$ /$1 [L,R=301]


	#redirect /index.php/*/*/....... to version without index.php

	RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]

	RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]


	# prevents files starting with dot to be viewed by browser

	RewriteRule /\.|^\. - [F]


	# front controller

	RewriteCond %{REQUEST_FILENAME} !-f

	RewriteCond %{REQUEST_FILENAME} !-d

	RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz|map)$ index.php [L]

</IfModule>


# enable gzip compression

<IfModule mod_deflate.c>

	<IfModule mod_filter.c>

		AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json application/xml image/svg+xml

	</IfModule>

</IfModule>